@@ -27,6 +27,17 @@ const libdocUi = {
2727 searchClearBtns : document . querySelectorAll ( '.search_form__clear_btn' ) ,
2828 ftocHeadings : [ ]
2929 } ,
30+ getTransferSize : function ( ) {
31+ // https://jmperezperez.com/blog/page-load-footer/
32+ let result = 0 ;
33+ if ( typeof performance == 'object' ) {
34+ result = performance . getEntriesByType ( 'resource' ) . reduce ( ( a , r ) => {
35+ return a + r . transferSize ;
36+ } , 0 ) ;
37+ result = Math . round ( result / 1024 ) ;
38+ }
39+ return result ;
40+ } ,
3041 getCurrentScreenSizeName : function ( ) {
3142 let response = '' ;
3243 Object . keys ( libdocUi . defaults . screenSizes ) . forEach ( function ( name ) {
@@ -285,6 +296,7 @@ const libdocUi = {
285296 _toggleFtocLargeDevices : function ( evt ) {
286297 if ( libdocUi . el . ftocDetails . open ) {
287298 libdocUi . updateUserPreferences ( { FTOCNormallyOpened : true } ) ;
299+ libdocUi . updateFtocList ( ) ;
288300 } else {
289301 libdocUi . updateUserPreferences ( { FTOCNormallyOpened : false } ) ;
290302 }
@@ -322,6 +334,7 @@ const libdocUi = {
322334 } ) ;
323335 }
324336 libdocUi . updateSearchInputClearBtns ( ) ;
337+ libdocUi . updateTransferSizeDisplay ( ) ;
325338 } ,
326339 _navPrimaryCheckboxChange : function ( evt ) {
327340 libdocUi . updateNavPrimary ( ) ;
@@ -404,7 +417,14 @@ const libdocUi = {
404417 }
405418 }
406419 } ,
407-
420+ updateTransferSizeDisplay : function ( ) {
421+ const currentTransferSize = libdocUi . getTransferSize ( ) ;
422+ if ( currentTransferSize > 0 ) {
423+ document . querySelectorAll ( '.page-transfer-size-display' ) . forEach ( function ( el ) {
424+ el . innerHTML = `${ currentTransferSize } kB` ;
425+ } )
426+ }
427+ } ,
408428 updateSearchInputClearBtns : function ( ) {
409429 libdocUi . el . searchInputs . forEach ( function ( elInput ) {
410430 const elClearBtn = elInput . form . querySelector ( '.search_form__clear_btn' ) ;
@@ -561,7 +581,7 @@ const libdocUi = {
561581 updateGTTBtns : function ( ) {
562582 if ( window . scrollY > libdocUi . el . mainHeader . clientHeight ) {
563583 libdocUi . enableGTTLargeDevices ( ) ;
564- if ( getComputedStyle ( libdocUi . el . navPrimaryContainer ) != 'none' ) {
584+ if ( getComputedStyle ( libdocUi . el . navPrimaryContainer ) . display != 'none' ) {
565585 libdocUi . disableGTTSmallDevices ( ) ;
566586 } else {
567587 libdocUi . enableGTTSmallDevices ( ) ;
@@ -616,7 +636,7 @@ const libdocUi = {
616636 } ,
617637 updateFTOCBtns : function ( ) {
618638 if ( libdocUi . el . tocMainOl !== null ) {
619- if ( getComputedStyle ( libdocUi . el . navPrimaryContainer ) != 'none' ) {
639+ if ( getComputedStyle ( libdocUi . el . navPrimaryContainer ) . display != 'none' ) {
620640 libdocUi . el . navSmallDevicesFTOCBtn . disabled = true ;
621641 } else {
622642 libdocUi . el . navSmallDevicesFTOCBtn . disabled = false ;
@@ -873,7 +893,6 @@ const libdocUi = {
873893 libdocUi . fitSvgToItsContent ( el )
874894 } ) ;
875895 document . body . addEventListener ( 'touchstart' , libdocUi . handlers . _touchStart ) ;
876- // document.addEventListener('selectionchange', libdocUi.handlers._selectionChange);
877896 }
878897}
879898libdocUi . update ( ) ;
0 commit comments