1// Forums JavaScript helpers 2 3// Update URL in browser without navigation (using History API) 4window.updateUrlWithoutNavigation = function (url) { 5 if (window.history && window.history.pushState) { 6 window.history.pushState({ path: url }, '', url); 7 } 8}; 9 10// Replace URL in browser without navigation (doesn't add to history) 11window.replaceUrlWithoutNavigation = function (url) { 12 if (window.history && window.history.replaceState) { 13 window.history.replaceState({ path: url }, '', url); 14 } 15}; 16 17// Scroll to element by id 18window.scrollToElement = function (elementId) { 19 var element = document.getElementById(elementId); 20 if (element) { 21 element.scrollIntoView({ behavior: 'smooth', block: 'start' }); 22 } 23}; 24 25// Scroll to top of page 26window.scrollToTop = function () { 27 window.scrollTo({ top: 0, behavior: 'smooth' }); 28}; 29 30// ============================================================ 31// Auto-growing textareas (private-message composer, etc.) 32// ------------------------------------------------------------ 33// Any <textarea class="pm-autogrow"> grows with its content past its 34// starting rows, up to data-autogrow-max px, then scrolls. Uses event 35// delegation on document so it works with Blazor's dynamically-rendered 36// DOM without per-element setup. 'input' fires on typing AND on paste, 37// so multiline copy-paste resizes correctly. Programmatic value changes 38// (e.g. Blazor clearing the box after send) don't fire 'input', so the 39// code-behind calls window.teqPmResetAutogrow() to collapse it back. 40// ============================================================ 41(function () { 42 function grow(ta) { 43 var max = parseInt(ta.getAttribute('data-autogrow-max'), 10) || 200; 44 ta.style.height = 'auto'; 45 var target = Math.min(ta.scrollHeight, max); 46 ta.style.height = target + 'px'; 47 ta.style.overflowY = ta.scrollHeight > max ? 'auto' : 'hidden'; 48 } 49 50 function handle(e) { 51 var t = e.target; 52 if (t && t.classList && t.classList.contains('pm-autogrow')) { 53 grow(t); 54 } 55 } 56 57 document.addEventListener('input', handle); 58 // Focus catches the first render / when a conversation opens. 59 document.addEventListener('focusin', handle); 60 61 // Collapse every auto-grow textarea back to its start size (called after 62 // the composer is cleared on send). 63 window.teqPmResetAutogrow = function () { 64 document.querySelectorAll('textarea.pm-autogrow').forEach(grow); 65 }; 66})(); 67
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.