PageSourceSearch

https://mentalhealthandwellbeing.eu/files/_themes/mentalhealth/js/toc_trigger.js

js mentalhealthandwellbeing.eu collected 2026-10-04 00:17:29 UTC 2,999 bytes, 80 lines download raw bytes

1;(function( $ ){
2    'use strict';
3
4    var addMarginToContentTitle = function() {
5        var $contentTitle = $('.content-title'),
6            $contentNav = $('.content-navigation'),
7            $contentTitleHeight = $('.content-title').height(),
8            $contentNavHeight = $contentNav.height() + 40,
9            magicNumber = 50;
10
11        $contentNav.css('margin-top', $contentTitleHeight - $contentTitle.offset().top + magicNumber + 'px');
12        $contentTitle.css('margin-bottom', $contentNavHeight + 'px');
13    };
14
15
16    // Verifica a largura de um elemento
17    // Se a largura for menor que 752 significa que está
18    // nos media queries mobile e como tal tem de adicionar o botão 'menu'
19    var checkElementWidth = function(){
20        var $el = $('.header-top'),
21            $elWidth = $el.width(),
22            mediaQueryWidth = 752;
23
24        if( $elWidth <= mediaQueryWidth ){
25            addMarginToContentTitle();
26        } else if( $elWidth > mediaQueryWidth){
27            $('.content-title').removeAttr('style');
28        }
29    };
30
31    $(window).on('load', function(){
32        var stripAccents = (function () {
33            var in_chrs   = 'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ',
34                out_chrs  = 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY',
35                chars_rgx = new RegExp('[' + in_chrs + ']', 'g'),
36                transl    = {}, i,
37                lookup    = function (m) { return transl[m] || m; };
38
39            for (i=0; i<in_chrs.length; i++) {
40                transl[ in_chrs[i] ] = out_chrs[i];
41            }
42            return function (s) {
43                return s.replace(chars_rgx, lookup)
44                        .replace(/\s+/g, '-')
45                        .replace(/[^a-z0-9-]/gi,'-')
46                        .replace(/-+$|(-)+/g, '$1');
47            };
48        })();
49
50        if( $('.content h3').size() >= 2 ){
51            $('#main .wrapper').prepend('<nav role="navigation" class="content-navigation"></nav>');
52
53            $('.content-navigation')
54                .toc({
55                    'selectors': '> h3, div h3, blockquote h3',
56                    'container': '.content',
57                    'prefix': 'toc',
58                    'highlightOnScroll': true,
59                    'highlightOffset': 20,
60                    'scrollToOffset': -20,
61                    'anchorName': function(i, heading) {
62                        return stripAccents( $.trim($(heading).text().toLowerCase()) );
63                    }
64                })
65                .boqAffix({
66                    startAt: $('.content-navigation'),
67                    finishAt: $('body > footer'),
68                    offsettop: 10,
69                    offsetbottom: 50
70                })
71                .find('ul').addClass('content-menu');
72        }
73
74        checkElementWidth();
75    });
76
77    $(window).on('resize', function(){
78        debounce(checkElementWidth(), 100);
79    });
80})(jQuery);

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.