1;(function($){ 2 $(function(){ 3 var $fab = $('.js-floating'); 4 if (!$fab.length) { return; } 5 6 var $btn = $fab.find('.js-floating__btn'); 7 var $popover = $fab.find('.js-floating__popover'); 8 var $inner = $fab.find('.js-floating__popover-inner'); 9 10 function openFab() { 11 $fab.addClass('floating--active'); 12 $btn.addClass('is-active'); 13 $popover.addClass('is-visible'); 14 $('body').addClass('bl-lock'); 15 } 16 17 function closeFab() { 18 $fab.removeClass('floating--active'); 19 $btn.removeClass('is-active'); 20 $popover.removeClass('is-visible'); 21 $('body').removeClass('bl-lock'); 22 } 23 24 function recalcHeight() { 25 if (!$inner.length) return; 26 try { 27 // reset explicit height to measure content 28 $inner[0].style.height = ''; 29 var h; 30 if ($fab.hasClass('floating--active')) { 31 // when visible, rely on popover box height (like CodyHouse) 32 h = $popover[0] ? ($popover[0].offsetHeight + 1) : 0; 33 } else { 34 // fallback when closed: use content scrollHeight 35 h = $inner[0].scrollHeight + 1; 36 } 37 if (h && isFinite(h)) { 38 var hp = Math.ceil(h); 39 // set CSS var and lock inner height for clipping animation 40 $fab[0].style.setProperty('--fab-popover-height', hp + 'px'); 41 $inner[0].style.height = hp + 'px'; 42 } 43 } catch(e) {} 44 } 45 46 $btn.on('click', function(e){ 47 e.preventDefault(); 48 if ($fab.hasClass('floating--active')) { 49 closeFab(); 50 } else { 51 openFab(); 52 // measure after styles apply 53 requestAnimationFrame(function(){ recalcHeight(); }); 54 } 55 }); 56 57 // Close when clicking overlay inside this floating container only 58 $fab.on('click', function(e){ 59 if (!$fab.hasClass('floating--active')) return; 60 var $t = $(e.target); 61 if ($t.closest('.js-floating__popover, .js-floating__btn').length) return; // ignore clicks on content and toggle 62 // clicked within the floating overlay area 63 closeFab(); 64 }); 65 66 // Close on Escape 67 $(document).on('keydown', function(e){ 68 if (e.key === 'Escape') { closeFab(); } 69 }); 70 71 // Recalculate on resize/orientation change 72 var resizeTO; 73 $(window).on('resize orientationchange', function(){ 74 clearTimeout(resizeTO); 75 resizeTO = setTimeout(function(){ recalcHeight(); }, 100); 76 }); 77 78 // Initial calc in case content has dynamic height 79 if (document.fonts && document.fonts.ready) { 80 document.fonts.ready.then(function(){ recalcHeight(); }); 81 } else { 82 recalcHeight(); 83 } 84 }); 85})(jQuery); 86
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.