PageSourceSearch

https://audioguidesapp.com/wp-content/plugins/easy-table-of-contents/assets/js/front.js?ver=2.0.85-1785143111

js audioguidesapp.com collected 2026-09-24 13:38:50 UTC 17,747 bytes, 385 lines download raw bytes

1jQuery( function( $ ) {
2
3	/**
4	 * @typedef ezTOC
5	 * @type {Object} ezTOC
6	 * @property {string} affixSelector
7	 * @property {string} scroll_offset
8	 * @property {string} smooth_scroll
9	 * @property {string} visibility_hide_by_default
10	 */
11
12	if ( typeof ezTOC != 'undefined' ) {
13
14		/**
15		 * Init EZ TOC.
16		 */
17		function ezTOCInit() {
18
19		var affix = $( '.ez-toc-widget-container.ez-toc-affix' );
20
21		if ( 0 !== affix.length ) {
22
23			/**
24			 * The smooth scroll offset needs to be taken into account when defining the offset_top property.
25			 * @link https://github.com/shazahm1/Easy-Table-of-Contents/issues/19
26			 *
27			 * @type {number}
28			 */
29			var affixOffset = 30;
30
31			// check offset setting
32			if ( typeof ezTOC.scroll_offset != 'undefined' ) {
33
34				affixOffset = parseInt( ezTOC.scroll_offset );
35			}
36
37			$( ezTOC.affixSelector ).stick_in_parent( {
38				inner_scrolling: false,
39				offset_top:      affixOffset
40			} )
41		}
42
43		$.fn.shrinkTOCWidth = function() {
44
45			$( this ).css( {
46				width:   'auto',
47				display: 'table'
48			});
49
50			if ( /MSIE 7\./.test( navigator.userAgent ) )
51				$( this ).css( 'width', '' );
52		};
53
54
55		if ( typeof ezTOC.visibility_hide_by_default != 'undefined' ) {
56
57			// Get all toggles that have not been loaded.
58			var toggles = $( '.ez-toc-toggle:not(.ez-toc-loaded),.ez-toc-widget-sticky-toggle:not(.ez-toc-loaded)' ); 
59            var invert_device =  (typeof ezTOC.visibility_hide_by_device != 'undefined') ? ezTOC.visibility_hide_by_device : 0;
60			var invert = ezTOC.visibility_hide_by_default;
61            
62
63                        $.each(toggles, function(i, obj) {
64                            
65                            var toggle = $(this);
66                            $(toggle).addClass('ez-toc-loaded'); // Attach loaded class.
67                            var toc = $( toggle ).parents('#ez-toc-container,#ez-toc-widget-container,#ez-toc-widget-sticky-container').find( 'ul.ez-toc-list,ul.ez-toc-widget-sticky-list' );
68                            if($(toc).hasClass('eztoc-toggle-hide-by-default')){
69                                invert = 1;
70                            }                                
71                            if (typeof Cookies !== "undefined") {
72                                if ( Cookies ) {
73
74                                        if ( Cookies.get( 'ezTOC_hidetoc-' + i ) == 1 ) {
75                                            $(toggle).data( 'visible', false );
76                                            // Add toc_close class when cookie indicates TOC should be hidden
77                                            const main = document.querySelector("#ez-toc-container");
78                                            if(main){
79                                                    main.classList.add("toc_close");
80                                            }
81                                            else
82                                            {
83                                                    const side = document.querySelector(".ez-toc-widget-container,.ez-toc-widget-sticky-container");
84                                                    if(side) {
85                                                        side.classList.add("toc_close");
86                                                    }
87                                            }
88                                        } else {
89                                            $(toggle).data( 'visible', true );
90                                        }
91                                        Cookies.remove('ezTOC_hidetoc-' + i)
92
93                                } else {
94
95                                        $(toggle).data( 'visible', true );
96                                        Cookies.remove('ezTOC_hidetoc-' + i);
97                                }
98                            }
99
100                            if ( invert && invert_device != '0') {
101
102                                    $(toggle).data( 'visible', false )
103                            }
104
105                            if ( ! $(toggle).data( 'visible' ) ) {
106
107                                    toc.hide();
108                                    // Set initial box title state when TOC is hidden by default
109                                    const main = document.querySelector("#ez-toc-container");
110                                    if(main){
111                                            const boxTitle = main.querySelector('.ez-toc-box-title');
112                                            if(boxTitle){
113                                                    boxTitle.classList.add("toc-closed");
114                                            }
115                                    } else {
116                                            const side = document.querySelector(".ez-toc-widget-container,.ez-toc-widget-sticky-container");
117                                            if(side){
118                                                    const boxTitle = side.querySelector('.ez-toc-box-title');
119                                                    if(boxTitle){
120                                                            boxTitle.classList.add("toc-closed");
121                                                    }
122                                            }
123                                    }
124                            }
125
126                            $(toggle).on( 'click', function( event ) {
127
128                                    event.preventDefault();
129
130                                    const main = document.querySelector("#ez-toc-container");
131                                    if(main){
132                                            main.classList.toggle("toc_close");
133                                            // Handle box title positioning
134                                            const boxTitle = main.querySelector('.ez-toc-box-title');
135                                            if(boxTitle){
136                                                    boxTitle.classList.toggle("toc-closed");
137                                            }
138                                    }
139                                    else
140                                    {
141                                            const side = document.querySelector(".ez-toc-widget-container,.ez-toc-widget-sticky-container");
142                                            side.classList.toggle("toc_close");
143                                            // Handle box title positioning for side widgets
144                                            const boxTitle = side.querySelector('.ez-toc-box-title');
145                                            if(boxTitle){
146                                                    boxTitle.classList.toggle("toc-closed");
147                                            }
148                                    }
149
150                                    if ( $( this ).data( 'visible' ) ) {
151
152                                            $( this ).data( 'visible', false );
153                                            if (typeof Cookies !== "undefined") {
154                                                if ( Cookies ) {
155
156                                                        if ( invert )
157                                                                Cookies.set( 'ezTOC_hidetoc-' + i, null, { path: '/', sameSite: 'Strict' } );
158                                                        else
159                                                                Cookies.set( 'ezTOC_hidetoc-' + i, '1', { expires: 30, path: '/', sameSite: 'Strict' } );
160                                                }
161                                            }
162
163                                            toc.hide( 'fast' );
164
165                                    } else {
166
167                                            $( this ).data( 'visible', true );
168                                            if (typeof Cookies !== "undefined") {
169                                                if ( Cookies ) {
170
171                                                        if ( invert )
172                                                                Cookies.set( 'ezTOC_hidetoc-' + i, '1', { expires: 30, path: '/', sameSite: 'Strict' } );
173                                                        else
174                                                                Cookies.set( 'ezTOC_hidetoc-' + i, null, { path: '/', sameSite: 'Strict' } );
175                                                }
176                                            }
177
178                                            toc.show( 'fast' );
179
180                                    }
181
182                            } );
183                        
184                        });
185		}
186
187
188        // ======================================
189        // Set active heading in ez-toc-widget list
190        // ======================================
191
192        var headings = $( 'span.ez-toc-section' ).toArray();
193        var headingToListElementLinkMap = getHeadingToListElementLinkMap( headings );
194        var listElementLinks = $.map( headingToListElementLinkMap, function ( value, key ) {
195            return value
196        } );
197        var scrollOffset = getScrollOffset();
198
199        activateSetActiveEzTocListElement();
200
201        function setActiveEzTocListElement() {
202            var activeHeading = getActiveHeading( scrollOffset, headings );
203            if ( activeHeading ) {
204                var activeListElementLink = headingToListElementLinkMap[ activeHeading.id ];
205                removeStyleFromNonActiveListElement( activeListElementLink, listElementLinks );
206                setStyleForActiveListElementElement( activeListElementLink );
207            }
208        }
209
210        function activateSetActiveEzTocListElement() {
211            if ( headings.length > 0 && $('.ez-toc-widget-container').length) {
212                $( window ).on( 'load resize scroll', setActiveEzTocListElement );
213            }
214        }
215
216        function deactivateSetActiveEzTocListElement() {
217            $( window ).off( 'load resize scroll', setActiveEzTocListElement );
218        }
219
220        function getEzTocListElementLinkByHeading( heading ) {
221            return $( '.ez-toc-widget-container .ez-toc-list a[href="#' + $( heading ).attr( 'id' ) + '"]' );
222        }
223
224        function getHeadingToListElementLinkMap( headings ) {
225            return headings.reduce( function ( map, heading ) {
226                map[ heading.id ] = getEzTocListElementLinkByHeading( heading );
227                return map;
228            }, {} );
229        }
230
231        function getScrollOffset() {
232            var scrollOffset = 5; // so if smooth offset is off, the correct title is set as active
233            if ( typeof ezTOC.smooth_scroll != 'undefined' && parseInt( ezTOC.smooth_scroll ) === 1 ) {
234                scrollOffset = ( typeof ezTOC.scroll_offset != 'undefined' ) ? parseInt( ezTOC.scroll_offset ) : 30;
235            }
236
237            var adminbar = $( '#wpadminbar' );
238
239            if ( adminbar.length ) {
240                scrollOffset += adminbar.height();
241            }
242            return scrollOffset;
243        }
244
245        function getActiveHeading( topOffset, headings ) {
246            var scrollTop = $( window ).scrollTop();
247            var relevantOffset = scrollTop + topOffset + 1;
248            var activeHeading = headings[ 0 ];
249            var closestHeadingAboveOffset = relevantOffset - $( activeHeading ).offset().top;
250            headings.forEach( function ( section ) {
251                var topOffset = relevantOffset - $( section ).offset().top;
252                if ( topOffset > 0 && topOffset < closestHeadingAboveOffset ) {
253                    closestHeadingAboveOffset = topOffset;
254                    activeHeading = section;
255                }
256            } );
257            return activeHeading;
258        }
259
260        function removeStyleFromNonActiveListElement( activeListElementLink, listElementLinks ) {
261            listElementLinks.forEach( function ( listElementLink ) {
262                if ( activeListElementLink !== listElementLink && listElementLink.parent().hasClass( 'active' ) ) {
263                    listElementLink.parent().removeClass( 'active' );
264                }
265            } );
266        }
267
268        function correctActiveListElementBackgroundColorHeight( activeListElement ) {
269            var listElementHeight = getListElementHeightWithoutUlChildren( activeListElement );
270            addListElementBackgroundColorHeightStyleToHead( listElementHeight );
271        }
272
273        function getListElementHeightWithoutUlChildren( listElement ) {
274            var $listElement = $( listElement );
275            var content = $listElement.html();
276            // Adding list item with class '.active' to get the real height.
277            // When adding a class to an existing element and using jQuery(..).height() directly afterwards,
278            // the height is the 'old' height. The height might change due to text-wraps when setting the text-weight bold for example
279            // When adding a new item, the height is calculated correctly.
280            // But only when it might be visible (so display:none; is not possible...)
281            // But because it get's directly removed afterwards it never will be rendered by the browser
282            // (at least in my tests in FF, Chrome, IE11 and Edge)
283            $listElement.parent().append( '<li id="ez-toc-height-test" class="active">' + content + '</li>' );
284            var listItem = $( '#ez-toc-height-test' );
285            var height = listItem.height();
286	        listItem.remove();
287            return height - ($listElement.children( 'ul' ).first().height() || 0);
288        }
289
290        function addListElementBackgroundColorHeightStyleToHead( listElementHeight ) {
291            // Remove existing
292            //$( '#ez-toc-active-height' ).remove();
293            // jQuery(..).css(..) doesn't work, because ::before is a pseudo element and not part of the DOM
294            // Workaround is to add it to head
295           // $( '<style id="ez-toc-active-height">.ez-toc-widget-container ul.ez-toc-list li.active {height:' + listElementHeight + 'px;' + '} </style>' ).appendTo( 'head' );
296		   $( '.ez-toc-widget-container ul.ez-toc-list li.active' ).css( 'height',listElementHeight + 'px' );
297        }
298
299        function setStyleForActiveListElementElement( activeListElementLink ) {
300            var activeListElement = activeListElementLink.parent();
301            if ( !activeListElement.hasClass( 'active' ) ) {
302                activeListElement.addClass( 'active' );
303            }
304            correctActiveListElementBackgroundColorHeight( activeListElement );
305        }
306    }
307    if($( '#ez-toc-container').length){
308        if(!$( '#ez-toc-container .ez-toc-toggle label span').html()){
309            $( '#ez-toc-container .ez-toc-toggle label').html(ezTOC.fallbackIcon);
310        }
311    }
312        
313    	/**
314		 * Attach global init handler to ezTOC window object.
315		 */
316		ezTOC.init = function(){
317			ezTOCInit();
318		}
319		// Start EZ TOC on page load.
320		ezTOCInit();
321
322        // Ensure proper column layout for TOC
323        function optimizeTOCColumns() {
324            $('.ez-toc-list[class*="ez-toc-columns-"]').each(function() {
325                var $list = $(this);
326                var columnClass = $list.attr('class').match(/ez-toc-columns-(\d+)/);
327                if (!columnClass) return;
328                
329                var columns = parseInt(columnClass[1]);
330                if (columns <= 1) return;
331                
332                // Add CSS class for better column balancing
333                $list.addClass('ez-toc-columns-optimized');
334                
335                // Ensure items don't break across columns inappropriately
336                $list.find('li').each(function() {
337                    var $item = $(this);
338                    var itemHeight = $item.outerHeight();
339                    
340                    // If item is too tall, prevent it from breaking
341                    if (itemHeight > 50) {
342                        $item.css('break-inside', 'avoid');
343                    }
344                });
345            });
346        }
347
348        // Run column optimization after TOC is initialized
349        setTimeout(optimizeTOCColumns, 100);
350
351        if ( typeof ezTOC.ajax_toggle != 'undefined' && parseInt( ezTOC.ajax_toggle ) === 1 ) {
352            $( document ).ajaxComplete(function() {
353                ezTOCInit();
354                setTimeout(optimizeTOCColumns, 100);
355            });
356        }
357        
358	}
359    $(document).on('click', '#ez-toc-open-sub-hd', function(e) {
360        $(this).attr("id","ez-toc-open-sub-hd-active");
361        e.preventDefault();
362    });
363    $(document).on('click', '#ez-toc-open-sub-hd-active', function(e) {
364        $(this).attr("id","ez-toc-open-sub-hd");
365        e.preventDefault();
366    });    
367
368    $("#ez-toc-more-links-enabler").click(function () { 
369        $(".ez-toc-more-link").show();
370        $("#ez-toc-more-links-enabler").hide();
371        $("#ez-toc-more-links-disabler").attr("style","display:inline-block");
372    });
373    $("#ez-toc-more-links-disabler").click(function () { 
374        $(".ez-toc-more-link").hide();
375        $("#ez-toc-more-links-enabler").show();
376        $("#ez-toc-more-links-disabler").hide();
377    });
378
379    if ( parseInt( ezTOC.chamomile_theme_is_on ) === 1 ) {
380
381        $('#ez-toc-container').find('.hamburger').remove();
382        
383    }
384
385} );

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.