(function(F){ "use strict"; const P = F.page, D = F.dom; F.onPageLoad(function(){ const scrollbarIsVisible = (e)=>e.scrollHeight > e.clientHeight; const getWidgetHandler = function(widget, contentElem){ 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({ behavior: 'smooth' }); }else{ contentElem.classList.remove('shrunken'); } return false; }; }; document.querySelectorAll( 'div.forumTime, div.forumEdit' ).forEach(function f(forumPostWrapper){ const content = forumPostWrapper.querySelector('div.forumPostBody'); if(!content || !scrollbarIsVisible(content)) return; const parent = content.parentElement, widget = D.addClass( D.div(), 'forum-post-collapser','bottom' ), rightTapZone = D.addClass( D.div(), 'forum-post-collapser','right' ); const refillTapZone = function f(){ if(!f.baseTapIndicatorHeight){ 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.addEventListener('click', widgetEventHandler, false); 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(); }); if(F.pikchr){ F.pikchr.addSrcView(); } const formSubmitted = function(event){ const form = event.target; if( form.dataset.submitted ){ event.preventDefault(); return; } form.dataset.submitted = '1'; setTimeout(()=>{delete form.dataset.submitted}, 7000); return; }; document.querySelectorAll("form").forEach(function(form){ form.addEventListener('submit',formSubmitted); }); }); })(window.fossil);