Skip to content

Commit 0766845

Browse files
peterzhangsnailljharb
authored andcommitted
collapsable pin pane
1 parent 012d871 commit 0766845

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

css/elements.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ tr.del > td {
569569
white-space: nowrap;
570570
}
571571

572-
#menu-toc .item-toggle {
572+
#menu-toc .item-toggle, #menu-pins-header .item-toggle { /*add our collapsible pin pane button to it*/
573573
display: inline-block;
574574
transform: rotate(-45deg) translate(-5px, -5px);
575575
transition: transform 0.1s ease;
@@ -593,15 +593,15 @@ tr.del > td {
593593
width: 20px;
594594
}
595595

596-
#menu-toc li.active > .item-toggle {
596+
#menu-toc li.active > .item-toggle, #menu-pins-header.active > .item-toggle { /*add our collapsible pin pane button to it*/
597597
transform: rotate(45deg) translate(-5px, -5px);
598598
}
599599

600-
#menu-toc li > ol {
600+
#menu-toc li > ol, #menu-pins-header + #menu-pins-list { /*add our menu pins list to it*/
601601
display: none;
602602
}
603603

604-
#menu-toc li.active > ol {
604+
#menu-toc li.active > ol, #menu-pins-header.active + #menu-pins-list { /*add our menu pins list to it*/
605605
display: block;
606606
}
607607

js/menu.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function Menu() {
238238
document.addEventListener('keydown', this.documentKeydown.bind(this));
239239

240240
// toc expansion
241-
var tocItems = this.$menu.querySelectorAll('#menu-toc li');
241+
var tocItems = this.$menu.querySelectorAll('#menu-toc li, #menu-pins .menu-pane-header'); //Add our menu pin header to it(Can't use its id, we haven't added it now).
242242
for (var i = 0; i < tocItems.length; i++) {
243243
var $item = tocItems[i];
244244
$item.addEventListener('click', function($item, event) {
@@ -848,3 +848,20 @@ document.addEventListener('DOMContentLoaded', function () {
848848
Toolbox.init();
849849
referencePane.init();
850850
})
851+
852+
//Here's our collapsible pin pane
853+
document.addEventListener('DOMContentLoaded', collapsiblePinPane);
854+
855+
function collapsiblePinPane(){
856+
var MenuPins = document.getElementById('menu-pins');
857+
var MenuPaneHeader = MenuPins.querySelector('.menu-pane-header');
858+
MenuPaneHeader.setAttribute('id', 'menu-pins-header'); //Give the header an id for convenience.
859+
860+
var pinButton = document.createElement('span');
861+
pinButton.textContent = "◢";
862+
pinButton.setAttribute('class','item-toggle'); //Set its class attribute
863+
pinButton.style.cssFloat = 'right'; //Float the button to the right side, making it easier to be noticed.
864+
pinButton.style.color = 'black'; //Set a different color for it, so the button won't be mixed with the background.
865+
866+
MenuPaneHeader.appendChild(pinButton);
867+
}

0 commit comments

Comments
 (0)