Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Several forum style improvements based on forum feedback. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
2121b1f7a765114b7a50092617e1a879 |
| User & Date: | stephan 2020-08-14 17:57:25.468 |
Context
|
2020-08-14
| ||
| 18:54 | Consolidated the common styles of the bottom- and right-side forum post expansion toggles and resolved a layout quirk which could cause the right-side expander to sit too far to the left. check-in: db1afa75be user: stephan tags: trunk | |
| 17:57 | Several forum style improvements based on forum feedback. check-in: 2121b1f7a7 user: stephan tags: trunk | |
| 14:38 | fileedit: removed a call to blob_reserve() (optimization) because we have a report which seems to imply that it unconditionally fails on mingw 32-bit builds. check-in: b99c069a2c user: stephan tags: trunk | |
Changes
Changes to src/default.css.
| ︙ | ︙ | |||
773 774 775 776 777 778 779 |
div.forumHier > div > form,
div.forumTime > div > form,
div.forumHierRoot > div > form {
margin: 0.5em 0;
}
.forum-post-collapser {
font-size: 0.8em;
| | | < | > | | > > > > > > > > > | > > > > | > > > > > > | 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 |
div.forumHier > div > form,
div.forumTime > div > form,
div.forumHierRoot > div > form {
margin: 0.5em 0;
}
.forum-post-collapser {
font-size: 0.8em;
margin: 0 0 0.4em 0;
padding: 0;
height: 1.75em;
line-height: 1.75em;
/* ^^^ Those sizes are finely tuned for the current selection of
arrow characters. If those change, these should, too. Remember that
FF/Chrome simply do not agree on alignment with most values :/. */
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 0 0 0.5em 0.5em;
border-color: rgba(0, 0, 0, 0.2);
opacity: 0.8;
cursor: pointer;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.forum-post-collapser > span {
margin: 0 1em 0 1em;
vertical-align: middle;
}
.forum-post-collapser.expanded > span:before {
content: "⇡⇡⇡" /*reminder: FF/Chrome cannot agree on alignment of ⮝*/;
}
.forum-post-collapser:not(.expanded) > span:before {
content: "⇣⇣⇣";
}
div.forumPostBody{
max-height: 50em;
overflow: auto;
}
div.forumPostBody.with-expander {
display: flex;
flex-direction: row;
overflow: auto;
}
div.forumPostBody.with-expander:not(.expanded) > :first-child {
overflow-y: hidden;
}
div.forumPostBody.with-expander > *:first-child {
/* Main content DIV */
overflow: auto;
}
div.forumPostBody.with-expander.expanded > *:first-child {
margin-bottom: 0.5em /* try to suppress scroll bar */;
}
div.forumPostBody.with-expander > *:nth-child(2) {
/* "Tap zone" for expansion of the post, sits to the right of the
post's content. */
min-width: 1.25em;
max-width: 1.25em;
/*for testing only:*//*background: magenta;*/
margin: 0 0 0 0.2em /* leave a gap between this and the neighboring scrollbar */;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
border-radius: 0.1em;
cursor: pointer;
background-color: rgba(0, 0, 0, 0.05);
border: 1px solid rgba(0, 0, 0, 0.1);
border-bottom: 0;
border-radius: 0 0.5em 0 0;
border-color: rgba(0, 0, 0, 0.2);
opacity: 0.8;
}
div.forumPostBody.with-expander > *:nth-child(2) > span:before {
content: "⇣";
}
div.forumPostBody.with-expander.expanded > *:nth-child(2) > span:before {
content: "⇡";
}
div.forumPostBody.expanded {
max-height: initial;
}
div.forumPostBody.shrunken {
/* When an expandable post is un-expanded, it is shrunkend down
to this size instead of its original size. */
|
| ︙ | ︙ |
Changes to src/fossil.page.forumpost.js.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 |
return function(ev){
if(ev) ev.preventDefault();
const wasExpanded = widget.classList.contains('expanded');
widget.classList.toggle('expanded');
contentElem.classList.toggle('expanded');
if(wasExpanded){
contentElem.classList.add('shrunken');
| | > > > > > | | > > > > > > > > > > > > > > > > > > > | > < < < < < > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
return function(ev){
if(ev) ev.preventDefault();
const wasExpanded = widget.classList.contains('expanded');
widget.classList.toggle('expanded');
contentElem.classList.toggle('expanded');
if(wasExpanded){
contentElem.classList.add('shrunken');
contentElem.parentElement.scrollIntoView({
/* This is non-standard, but !(MSIE, Safari) supposedly support it:
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView#Browser_compatibility
*/ behavior: 'smooth'
});
}else{
contentElem.classList.remove('shrunken');
}
return false;
};
};
/* Adds an Expand/Collapse toggle to all div.forumPostBody
elements which are deemed "too large" (those for which
scrolling is currently activated because they are taller than
their max-height). */
document.querySelectorAll(
'div.forumHier, div.forumTime, div.forumHierRoot'
).forEach(function f(forumPostWrapper){
const content = forumPostWrapper.querySelector('div.forumPostBody');
if(!content || !scrollbarIsVisible(content)) return;
const parent = content.parentElement,
rightTapZone = D.div(),
widget = D.div();
/* Repopulates the rightTapZone with arrow indicators. Because
of the wildly varying height of these elements, This has to
be done dynamically at init time and upon collapse/expand. Will not
work until the rightTapZone has been added to the DOM. */
const refillTapZone = function f(){
if(!f.baseTapIndicatorHeight){
/* To figure out how often to place an arrow in the rightTapZone,
we simply grab the first header element from the page and use
its hight as our basis for calculation. */
const h1 = document.querySelector('h1, h2');
f.baseTapIndicatorHeight = h1.getBoundingClientRect().height;
}
D.clearElement(rightTapZone);
var rtzHeight = parseInt(window.getComputedStyle(rightTapZone).height);
do {
D.append(rightTapZone, D.span());
rtzHeight -= f.baseTapIndicatorHeight * 8;
}while(rtzHeight>0);
};
const handlerStep1 = getWidgetHandler(widget, content);
const widgetEventHandler = ()=>{ handlerStep1(); refillTapZone(); };
content.classList.add('with-expander');
widget.classList.add('forum-post-collapser');
widget.addEventListener('click', widgetEventHandler, false);
/** Append 3 children, which CSS will evenly space across the
widget. This improves visibility over having the label
in only the left, right, or center. */
var i = 0;
for( ; i < 3; ++i ) D.append(widget, D.span());
if(content.nextSibling){
forumPostWrapper.insertBefore(widget, content.nextSibling);
}else{
forumPostWrapper.appendChild(widget);
}
content.appendChild(rightTapZone);
rightTapZone.addEventListener('click', widgetEventHandler, false);
refillTapZone();
});
})/*onload callback*/;
})(window.fossil);
|