| | @@ -348,10 +348,54 @@ |
| 348 | 348 | x -= pRect.width/3*2; |
| 349 | 349 | } |
| 350 | 350 | f.popup.show(x, y); |
| 351 | 351 | }/*handleLegendClicked()*/; |
| 352 | 352 | |
| 353 | + (function(){/*Set up #chat-settings-button */ |
| 354 | + const settingsButton = document.querySelector('#chat-settings-button'); |
| 355 | + var popupSize = undefined/*placement workaround*/; |
| 356 | + const settingsPopup = new F.PopupWidget({ |
| 357 | + cssClass: ['fossil-tooltip', 'chat-settings-popup'], |
| 358 | + adjustY: function(y){ |
| 359 | + const rect = settingsButton.getBoundingClientRect(); |
| 360 | + return rect.top + rect.height; |
| 361 | + } |
| 362 | + }); |
| 363 | + settingsPopup.installClickToHide(); |
| 364 | + const btnToggleBody = D.button("Toggle page body"); |
| 365 | + D.append(settingsPopup.e, btnToggleBody); |
| 366 | + const toggleBody = function f(){ |
| 367 | + if(f.isHidden) D.removeClass(f.elemsToToggle, 'hidden'); |
| 368 | + else D.addClass(f.elemsToToggle, 'hidden'); |
| 369 | + f.isHidden = !f.isHidden; |
| 370 | + }; |
| 371 | + toggleBody.elemsToToggle = []; |
| 372 | + toggleBody.isHidden = false; |
| 373 | + document.body.childNodes.forEach(function(e){ |
| 374 | + if(!e.classList) return/*TEXT nodes and such*/; |
| 375 | + else if(!e.classList.contains('content')){ |
| 376 | + toggleBody.elemsToToggle.push(e); |
| 377 | + } |
| 378 | + settingsPopup.hide(); |
| 379 | + }); |
| 380 | + btnToggleBody.addEventListener('click', toggleBody); |
| 381 | + settingsButton.addEventListener('click',function(){ |
| 382 | + settingsPopup.show(settingsButton); |
| 383 | + }); |
| 384 | + /* Find an ideal X position for the popup, directly under the settings |
| 385 | + button, based on the size of the popup... */ |
| 386 | + settingsPopup.show(document.body); |
| 387 | + popupSize = settingsPopup.e.getBoundingClientRect(); |
| 388 | + settingsPopup.hide(); |
| 389 | + settingsPopup.options.adjustX = function(x){ |
| 390 | + const rect = settingsButton.getBoundingClientRect(); |
| 391 | + console.debug("popupSize = ",popupSize); |
| 392 | + return rect.right - popupSize.width; |
| 393 | + }; |
| 394 | + })()/*#chat-settings-button setup*/; |
| 395 | + |
| 396 | + |
| 353 | 397 | /** Callback for poll() to inject new content into the page. jx == |
| 354 | 398 | the response from /chat-poll. If atEnd is true, the message is |
| 355 | 399 | appended to the end of the chat list, else the beginning (the |
| 356 | 400 | default). */ |
| 357 | 401 | const newcontent = function f(jx,atEnd){ |
| 358 | 402 | |