File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 1- document . addEventListener ( 'DOMContentLoaded' , ( ) => {
1+ /**
2+ * SimpleTOC load function.
3+ */
4+ const simpletocLoad = function ( ) {
25 const buttons = document . querySelectorAll ( 'button.simpletoc-collapsible' ) ;
36
47 buttons . forEach ( ( button ) => {
@@ -17,4 +20,17 @@ document.addEventListener( 'DOMContentLoaded', () => {
1720 : '0px' ;
1821 } ) ;
1922 } ) ;
20- } ) ;
23+ }
24+
25+ // Allow others to call function if needed.
26+ window . simpletocLoad = simpletocLoad ;
27+
28+ // Check to see if the document is already loaded.
29+ if ( document . readyState === 'complete' || document . readyState !== 'loading' ) {
30+ simpletocLoad ( ) ;
31+ } else {
32+ // Fallback event if the document is not loaded.
33+ document . addEventListener ( 'DOMContentLoaded' , ( ) => {
34+ simpletocLoad ( ) ;
35+ } ) ;
36+ }
You can’t perform that action at this time.
0 commit comments