PageSourceSearch

https://tribunais.org.pt/Portals/_default/skins/dnnthemeportaljustica/scripts/core/main.js?cdv=3591

js tribunais.org.pt collected 2026-10-03 19:43:07 UTC 52,065 bytes, 1,218 lines download raw bytes

1var justica = justica || {};
2
3justica.MAIN = (function () {
4
5    return {
6        init: function () {
7
8            //    $(document).ready(function () {
9            //        $('.DnnModule:not(:has(.container-fluid))').addClass('container outer');
10            //});
11
12            //Adiciona ao button executa serviço o seguinte html
13            $(".moduloExecutaServico.start div div a").append('<i class="fa fa-chevron-right" aria-hidden="true"></i>');
14
15            ////Altura menu mobile
16            //$('.navbar-mobile .navbar-nav').height(window.innerHeight);
17
18            $('[data-control]').each(function (index, elem) {
19                var data = $(elem).data(),
20                    control = data.control;
21
22                if (!justica[control]) return;
23
24                if (typeof justica[control] === 'function') {
25                    var obj = new justica[control];
26                    obj.init(elem, data);
27                } else if (typeof justica[control] === 'object') {
28                    justica[control].init(elem, data);
29                }
30            });
31
32            //-------------- barra de cookies
33            //var justicagovpt_cookies = "justicagovpt_cookies";
34
35            //Adiciona barra de cookies caso não tenha sido aceite
36
37
38            //-------------- MENU ##############
39            //var elMenuLink = $('ul.navbar-nav li > a, ul.navbar-nav li > span');
40
41            //MENU MOBILE REMOVE BUTTON NO CHILD && REMOVER BORDER MENU
42
43            if ($('.desktop_nav.nav.navbar-nav li').length == 0) {
44                $('button').remove();
45                $('.navbar ul.desktop_nav').css('border-top', 'none');
46
47            }
48
49            //-------------- SUBMENU height DESKTOP
50            //if ($(window).width() > 892) {
51
52            $("ul.nav > .menu_item.dropdown > ol.dropdown-menu").each(function () {
53                $(this).attr('data-height', $(this).height());
54                $(this).height(0);
55                $(this).css('opacity', 'inherit');
56            });
57
58            var menuButtons = $("ul.nav > .menu_item.dropdown");
59
60            menuButtons.click(function (e) {
61                //menuButtons.addClass("open");
62                var openMenu = $("ul.nav > .menu_item.dropdown.open");
63                var menuDropdownPane = $(this).children('ol.dropdown-menu');
64
65                //reset menu
66                menuButtons.removeClass('open');
67                $(this).children('.sub_menu_title').removeClass('onactive');
68
69
70                if (!openMenu.length || !openMenu.is(menuDropdownPane.parent())) {
71
72                    $(this).children('.sub_menu_title').addClass('onactive');
73
74                    //open menu
75                    menuDropdownPane.animate({
76                        height: parseInt(menuDropdownPane.attr('data-height')) + 20
77                    }, {
78                            queue: false,
79                            duration: 250
80                        });
81
82                    //toggle classe active menu
83                    //$(this).children('a, span').toggleClass('onactive');
84                    $('ol.dropdown-menu').height(0);
85                    $('.dropdown.open').removeClass('open');
86
87                    //add classe menu
88                    $(this).closest('.menu_item.dropdown').addClass('open');
89                } else {
90                    $(this).children('.sub_menu_title').removeClass('onactive');
91                    $('ol.dropdown-menu').height(0);
92                }
93
94                e.stopPropagation();
95            });
96
97            //close menu
98
99            $('body').click(function () {
100                if ($("ul.nav > .menu_item.dropdown.open").length) {
101                    $('ol.dropdown-menu').height(0);
102                    $('.dropdown .open').removeClass('open');
103                    $('.dropdown.open').removeClass('open');
104                }
105            });
106            $('.dropdown-menu').click(function (e) {
107                e.stopPropagation();
108            });
109
110            // } else {
111
112            //MENU MOBILE
113            //if (/iPad|iPhone|iPod/.test(navigator.platform) == true) {
114            //    $('.button_menu_mobile').on('click', function () {
115            //        if ($('.button_menu_mobile').hasClass('collapsed')) {
116            //            $('html').css('overflow', 'hidden');
117            //            $('body').css('overflow', 'hidden');
118            //            $('html').css('position', 'relative');
119            //            $('body').css('position', 'relative');
120            //            $('html').css('height', '100%');
121            //            $('body').css('height', '100%');
122            //            //$('.navbar-mobile').css('position', 'relative');
123
124            //        } else {
125            //            $('body').css('overflow', 'visible');
126            //            $('html').css('overflow', 'visible');
127
128            //        }
129            //    });
130            //} else {
131
132
133            $('.button_menu_mobile').on('click', function () {
134                if ($('.button_menu_mobile').hasClass('collapsed')) {
135                    $('html').css('overflow', 'hidden');
136                    $('body').css('overflow', 'hidden');
137                    //$('html').css('position', 'relative');
138                    $('body').css('position', 'fixed');
139                    $('html').css('height', '100%');
140                    $('body').css('height', '100%');
141
142                    /*$('body').css('position', 'fixed');
143                    $('html').css('position', 'fixed');
144                    $('body').css('display', 'block');*/
145                    //$('.navbar-mobile').css('position', 'relative');
146
147                } else {
148                    $('body').css('overflow', 'visible');
149                    $('html').css('overflow', 'visible');
150                    $('body').css('position', '');
151                    $('html').css('height', '');
152                    $('body').css('height', '');
153                    /* $('body').css('position', '');
154                     $('html').css('position', '');
155                     $('body').css('display', 'none');*/
156                }
157
158            });
159
160            $('.navbar-mobile .dropdown>a').on('click', function (e) {
161
162                if ($(this).siblings('.dropdown-menu').is(':visible')) {
163
164                    //HIDE
165                    $(this).siblings('.dropdown-menu').hide('fast');
166                    $(this).siblings('.dropdown-menu').removeClass('opened');
167                    $(this).find('pre').css('transform', 'rotate(0deg)');
168
169                } else {
170
171                    //reset
172                    $('.navbar-mobile').find('pre').css('transform', 'rotate(0deg)');
173                    $(this).parent().siblings().children('.opened').hide('fast');
174                    $(this).parent().siblings().children('.opened').removeClass('opened');
175                    $(this).parent().children('.opened').hide('fast');
176
177                    //SHOW
178                    $(this).siblings('.dropdown-menu').show('fast');
179                    $(this).siblings('.dropdown-menu').addClass('opened');
180                    $(this).find('pre').css('transform', 'rotate(180deg)');
181                }
182                e.stopPropagation();
183            });
184
185            // }
186            //  }
187
188            //---------------------- Remover o Texto depois do pipe "|"
189            jQuery("ul.nav .no_child_description:contains(|)").each(function (idx, value) {
190                var oldText = jQuery(value).text();
191                jQuery(value).text(oldText.substr(0, oldText.indexOf('|')));
192            })
193
194            //-------------- Active search ##############
195
196            $('.search-bar input').on('focus', function () {
197                $('.searchInputContainer').addClass('focus');
198            });
199            $('.search-bar input').on('blur', function () {
200                $('.searchInputContainer').removeClass('focus');
201            });
202
203            //-------------- initialize slider news ##############
204            $('body:not(.dnnEditState) .responsive').slick({
205                dots: true,
206                infinite: false,
207                speed: 300,
208                arrows: false,
209                slidesToShow: 4,
210                slidesToScroll: 3,
211                adaptiveHeight: true,
212                responsive: [
213                    {
214                        breakpoint: 1024,
215                        settings: {
216                            slidesToShow: 3,
217                            slidesToScroll: 3,
218
219                        }
220                    },
221                    {
222                        breakpoint: 768,
223                        settings: {
224                            slidesToShow: 2,
225                            slidesToScroll: 2,
226
227                        }
228                    },
229                    {
230                        breakpoint: 425,
231                        settings: {
232                            slidesToShow: 1,
233                            slidesToScroll: 1,
234
235                        }
236                    }
237                ]
238            });
239
240            //-------------- initialize slider Destaques Organismos ##############
241            $('body:not(.dnnEditState) .destaquesorganismo-responsive').slick({
242                dots: true,
243                infinite: false,
244                speed: 300,
245                arrows: false,
246                slidesToShow: 4,
247                slidesToScroll: 3,
248                adaptiveHeight: true,
249                responsive: [
250                    {
251                        breakpoint: 1024,
252                        settings: {
253                            slidesToShow: 3,
254                            slidesToScroll: 3,
255
256                        }
257                    },
258                    {
259                        breakpoint: 768,
260                        settings: {
261                            slidesToShow: 2,
262                            slidesToScroll: 2,
263
264                        }
265                    },
266                    {
267                        breakpoint: 425,
268                        settings: {
269                            slidesToShow: 1,
270                            slidesToScroll: 1,
271
272                        }
273                    }
274                ]
275            });
276
277            //-------------- initialize slider graphs ##############
278            $('body:not(.dnnEditState) .graphs').slick({
279                dots: true,
280                infinite: false,
281                speed: 300,
282                arrows: false,
283                slidesToShow: 2,
284                slidesToScroll: 2,
285                adaptiveHeight: true,
286                responsive: [
287                    {
288                        breakpoint: 1200,
289                        settings: {
290                            slidesToShow: 2,
291                            slidesToScroll: 2,
292
293                        }
294                    },
295                    {
296                        breakpoint: 768,
297                        settings: {
298                            slidesToShow: 2,
299                            slidesToScroll: 2,
300
301                        }
302                    },
303                    {
304                        breakpoint: 514,
305                        settings: {
306                            slidesToShow: 2,
307                            slidesToScroll: 2,
308
309                        }
310                    },
311                    {
312                        breakpoint: 425,
313                        settings: {
314                            slidesToShow: 1,
315                            slidesToScroll: 1,
316
317                        }
318                    }
319                ]
320            });
321
322            //-------------- initialize slider news inner ##############
323            $('body:not(.dnnEditState) .responsiveinner').slick({
324                dots: false,
325                infinite: false,
326                speed: 300,
327                arrows: false,
328                slidesToShow: 3,
329                slidesToScroll: 2,
330                adaptiveHeight: true,
331                responsive: [
332                    {
333                        breakpoint: 1024,
334                        settings: {
335                            slidesToShow: 2,
336                            slidesToScroll: 2,
337
338                        }
339                    },
340                    {
341                        breakpoint: 768,
342                        settings: {
343                            slidesToShow: 2,
344                            slidesToScroll: 2,
345
346                        }
347                    },
348                    {
349                        breakpoint: 500,
350                        settings: 'unslick'
351                    }
352                ]
353            });
354
355            //-------------- initialize slider CRONOGRAMA ##############
356            $('body:not(.dnnEditState) .cronograma').slick({
357                dots: true,
358                infinite: false,
359                speed: 300,
360                arrows: false,
361                slidesToShow: 8,
362                slidesToScroll: 4,
363                responsive: [
364                    {
365                        breakpoint: 1200,
366                        settings: {
367                            slidesToShow: 8,
368                            slidesToScroll: 4,
369
370                        }
371                    },
372                    {
373                        breakpoint: 768,
374                        settings: {
375                            slidesToShow: 5,
376                            slidesToScroll: 2,
377
378                        }
379                    },
380                    {
381                        breakpoint: 514,
382                        settings: {
383                            slidesToShow: 3,
384                            slidesToScroll: 2,
385
386                        }
387                    },
388                    {
389                        breakpoint: 425,
390                        settings: {
391                            slidesToShow: 1,
392                            slidesToScroll: 1,
393
394                        }
395                    }
396                ]
397            });
398
399            //init slider antes e depois na transformacao da justica
400            $('.antes_depois_slider').slick(
401                {
402                    dots: true,
403                    arrows: false,
404                    speed: 500,
405                    autoplay: true
406                });
407
408
409
410
411            //-------------- SCRIPT tooltip
412            $(function () {
413                $('[data-toggle="tooltip"]').tooltip()
414            })
415
416
417            //-------------- organismo collapse
418            $('.justica-documentos_organismo .doc .text').on('click', function () {
419                $(this).toggleClass('expanded');
420            });
421
422            $('.justica-servicos_organismo .wrap_list').on('click', function () {
423                $(this).toggleClass('height_open');
424            });
425
426            //--------------SCROLL EVENTS
427            //cta sticky bottom
428            $('.sticky_bottom').css({
429                "-webkit-transform": "translate(-50%, 80px)"
430            });
431            $(window).bind('scroll', function () {
432
433                //-------------- cta_SERVICOS when scrolls it appears
434                var stickyEl = $('.sticky_bottom'),
435                    elHeight = stickyEl.height(),
436                    distTop = 0;
437
438                if ($('aside .buttonExecutaServico.start').length > 0) {
439                    distTop = $('aside .buttonExecutaServico.start').offset().top;
440                }
441
442                if ($(window).scrollTop() > distTop) {
443
444                    $('body').css('margin-bottom', elHeight + 'px');
445
446                    stickyEl.css({
447                        "-webkit-transform": "translate(-50%, 0px)"
448                    });
449                } else {
450                    $('body').css('margin-bottom', 'inherit');
451
452                    stickyEl.css({
453                        "-webkit-transform": "translate(-50%, 80px)"
454                    });
455                }
456
457                //------------- content inner nav script on mobile
458                var innerNavMain = $('.menu_blue_content').first(),
459                    innerNavAside = $('aside .menu_blue_content'),
460                    elHeight = innerNavMain.height(),
461                    diffTopMain = 0;
462
463
464                //validate if exists
465                if (innerNavMain.length > 0) {
466                    diffTopMain = innerNavMain.offset().top;
467                }
468
469                if ($(window).scrollTop() > diffTopMain) {
470                    //add to aside
471                    innerNavAside.show();
472                    if (innerNavAside.length == 0) {
473                        innerNavMain.clone(true, true).addClass('contentNavAside contNav').appendTo('aside');
474                        innerNavMain.clone(true, true).addClass('contentNavBody contNav').appendTo('body');
475                        innerNavAside = $('aside .menu_blue_content');
476                        if (innerNavAside.length == 1) {
477                            diffTopAside = innerNavAside.offset().top;
478                        }
479                        //MOBILE interaction
480                        $(".menu_blue_content.contentNavBody").on('click', function () {
481                            var thisEl = $(this),
482                                elParent = thisEl; if (thisEl.hasClass('clicked')) {
483                                    console.log('hide');
484                                    thisEl.removeClass('clicked');
485                                    elParent.animate({
486                                        right: -235
487                                    }, {
488                                            easing: 'swing',
489                                            duration: 300,
490                                            complete: function () {
491                                                elParent.removeClass('open');
492                                            }
493                                        });
494                                } else {
495                                console.log('show');
496
497                                elParent.animate({
498                                    right: 0
499                                }, {
500                                        easing: 'swing',
501                                        duration: 300,
502                                        complete: function () {
503                                            thisEl.addClass('clicked');
504                                        }
505                                    });
506                                elParent.addClass('open');
507                            }
508
509                        });
510                    }
511                } else {
512                    //hide
513                    innerNavAside.hide();
514                }
515
516
517
518                //fix to top blue nav
519                if (innerNavAside.length > 0 && $(window).width() > 768) {
520
521                    if (innerNavAside.hasClass('fixed') && $(window).scrollTop() < diffTopAside) {
522                        innerNavAside.removeClass('fixed');
523
524                        return;
525                    }
526
527                    if ($(window).scrollTop() > diffTopAside) {
528                        innerNavAside.addClass('fixed');
529                        checkOffset();
530                    }
531                }
532
533
534            });
535
536            function checkOffset() {
537                if ($('.menu_blue_content.contentNavAside.contNav.fixed').offset().top + $('.menu_blue_content.contentNavAside.contNav.fixed').height()
538                    >= $('#footer').offset().top) {
539                    $('.menu_blue_content.contentNavAside.contNav.fixed').css('top', '-280px');
540                }
541                if ($(document).scrollTop() + window.innerHeight < $('#footer').offset().top) {
542                    //$('.menu_blue_content.contentNavAside.contNav.fixed').css('position', 'fixed');// restore when you scroll up
543                    $('.menu_blue_content.contentNavAside.contNav.fixed').css('top', '0');
544                }
545
546            }
547
548            //FILTROS PESQUISA MOBILE
549            $(".justica-pesquisa_body aside").find('.filter').on('click', function () {
550                var thisEl = $(this),
551                    elParent = thisEl.parent('aside');
552
553                if (thisEl.hasClass('clicked')) {
554
555                    thisEl.removeClass('clicked');
556                    elParent.animate({
557                        right: -205
558                    }, {
559                            easing: 'swing',
560                            duration: 300,
561                            complete: function () {
562                                elParent.removeClass('open');
563                            }
564                        });
565                } else {
566
567                    elParent.animate({
568                        right: 0
569                    }, {
570                            easing: 'swing',
571                            duration: 300,
572                            complete: function () {
573                                thisEl.addClass('clicked');
574                            }
575                        });
576                    elParent.addClass('open');
577                }
578            });
579
580            //RESULTADOS DE PESQUISA (FILTROS)
581            $(".justica-pesquisa_body aside").find("input").on('change', function () {
582                $(this).each(function () {
583                    var thisID = $(this).val();
584                    if ($(this).is(':checked')) {
585                        //SHOW
586                        $('#' + thisID).show('slow');
587                    } else {
588                        //HIDE
589                        $('#' + thisID).hide('slow');
590                    }
591                })
592            });
593
594            //Script feedback
595            justica.MAIN.InPageNavigation.init();
596            justica.MAIN.ReplicateServiceButtons.init();
597            justica.MAIN.ReplicateHomeTematicas2Mobile.init();
598            justica.MAIN.Footer.init();
599            justica.MAIN.CookieBar.init();
600            justica.MAIN.UserAuthentication.init();
601            justica.MAIN.Masonry.init();
602            justica.MAIN.newsletter.init();
603            justica.MAIN.DisplayChatbot.init();
604            justica.MAIN.ImageInject.init();
605            justica.MAIN.InjectButtonExecutaServico.init();
606            justica.MAIN.ManageLanguageDropDown.init();
607        },
608
609        //PREVENT MORE THAN n words in news titles and organisms (DELETE WHEN DONE FROM DATABASE)
610        maxWordCount: function () {
611            var news_title = $('.news-title:not(.big_headline)'),
612                organism = $('p.organismo:not(.big_headline)'),
613                maxLengthOrg = 30,
614                maxLengthNews = 70,
615                dots = "...";
616
617            news_title.each(function () {
618                var titleText = $.trim($(this).text());
619                if (titleText.length >= maxLengthNews) {
620                    $(this).text(titleText.substring(0, maxLengthNews) + dots);
621                }
622
623            });
624
625            organism.each(function () {
626                var titleText = $.trim($(this).text());
627                if (titleText.length >= maxLengthOrg) {
628                    $(this).text(titleText.substring(0, maxLengthOrg) + dots);
629                }
630
631            });
632        },
633
634        InPageNavigation: {
635            init: function initInPageNavigation() {
636                jQuery(".justica-noticias_single h2, .justica-guias_single h2, .ModDNNHTMLC h2, .justica-guias_single h3, .justica-noticias_single h3, .ModDNNHTMLC h3, .justica-guias_single h4, .justica-noticias_single h4, .ModDNNHTMLC h4, .aside_row.menu_topo.detalhe_service_link ").each(function (key, value) {
637
638                    $(this).html($(this).html().replace(/&nbsp;/g, ' '));
639
640                    var item = jQuery(value);
641                    if (jQuery(value).prop("tagName") != "A") {
642                        if (item.text().length > 0)
643                            item.attr('id', item.text().replace(/%20| |[^\w\s]/g, ""));
644                    } else {
645                        if (item.attr('href') != undefined && item.attr('href').startsWith("#")) {
646                            item.attr('href', item.attr('href').replace(/%20| |[^\w\s]/g, ""));
647                            item.attr('href', "#" + item.attr('href'));
648                        }
649                    }
650
651                });
652
653                jQuery('.justica-LP_body_generic a[href*=\\#], .ModDNNHTMLC a[href*=\\#]').on('click', function (e) {
654                    jQuery('html,body').animate({
655                        scrollTop: $(this.hash/*.replace(/%20| |[^\w\s]/g, "")*/).offset().top
656                    }, 500);
657                });
658
659                if (window.location.hash != "" && window.location.hash.length > 1) {
660                    jQuery('html,body').animate({
661                        scrollTop: function () {
662                            if (window.location.hash.length <= 0) {
663                                return;
664                            }
665                            var navHash = decodeURIComponent(window.location.hash).replace(/%20| |[^\w\s]/g, "");
666                            var navElement = jQuery(navHash);
667                            if (navElement.length > 0) {
668                                navElement.offset().top
669                            }
670                        }
671                    }, 500);
672                }
673
674            }
675        },
676
677        ReplicateServiceButtons: {
678            init: function initReplicateServiceButtons() {
679
680                if ($('section').hasClass('justica-LP_body_servicos') || $('section').hasClass('justica-LP_head_generic')) {
681                    var buttons = $("aside .buttonExecutaServico");
682
683                    $("aside .buttonExecutaServico").each(function (i) {
684                        var $elem = $(this).data("arr", [1]);
685                        // Deep copy to prevent data sharing
686                        var clone = $elem.clone(true, true).data("arr", $.extend([], $elem.data("arr")));
687
688                        $(clone).removeClass("hideTablet");
689
690                        $("section #buttons_mobile").append($(clone)[0]);
691                    });
692                }
693            }
694        },
695        InjectButtonExecutaServico: {
696            init: function () {
697                //if ($('.dnnModuleManager')[0]) {
698                //    if ($(".buttonExecutaServico").each(function (index, element) {
699                //    if ($(element).find('i').length > 0) {
700                //        $(element).find('i').remove();
701                //    }
702                //    }));
703                //} else {
704                //    if ($(".buttonExecutaServico").each(function (index, element) {
705
706                //            if ($(element).find('i').length == 0) {
707                //                $('<i class="fa fa-chevron-right" aria-hidden="true"></i>').appendTo($(element));
708
709                //    }
710                //    }));
711                //}
712                $('.dnnModuleManager').on("focusin", function () {
713
714                    $(this).find('.redactor-box .buttonExecutaServico').each(function (index, element) {
715                        if ($(element).find('i').length > 0) {
716                            $(element).find('i').remove();
717                        }
718                    });
719
720                });
721                $('.dnnModuleManager').on("focusout", function () {
722
723                    $(this).find('.redactor-box .buttonExecutaServico').each(function (index, element) {
724                        if ($(element).find('i').length == 0) {
725                            $('<i class="fa fa-chevron-right" aria-hidden="true"></i>').appendTo($(element));
726                        }
727                    });
728
729                });
730            }
731
732        },
733
734        ReplicateHomeTematicas2Mobile: {
735            init: function initReplicateHomeTematicas2Mobile() {
736                var containerFluid = jQuery('<div class="container-fluid tematicas visible-xs visible-sm"></div>');
737                var container = jQuery('<div class="container"></div>');
738
739                var content = jQuery('.justica-head_home .container-fluid.main_container .container .ContainerPane .DNNModuleContent').clone();
740
741                if (content.length > 0) {
742                    container.append(content);
743                    containerFluid.append(container);
744                    jQuery('.justica-head_home').append(containerFluid);
745                }
746            }
747        },
748
749        CookieBar: {
750            cookieName: "justicagovpt_cookies",
751
752            init: function initCookieBar() {
753                var userAgent = navigator.userAgent;
754                if (document.cookie.indexOf(this.cookieName) == -1 && userAgent != 'JusticaThumbCreator' && userAgent != 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)') {
755                    var cookieElem = jQuery('<div class="justica-cookie_bar sticky_top" data-control
755="cookie_bar"><div class="container"><div class="row"><div class="inner_top"><p><strong>Este website utiliza cookies.</strong> Ao continuar a navegação está a aceitar a sua utilização. Consulte a nossa <a href="https://justica.gov.pt/Avisos-Legais" target="_blank">política de privacidade</a></p><div class="accept">Fechar</div></div></div></div></div>');
756                    jQuery('body').append(cookieElem);
757                    jQuery('.sticky_top').css({
758                        "display": "block"
759                    });
760                }
761				//http://ec.europa.eu/ipg/basics/legal/cookies/index_en.htm
762
763                $('.accept').on('click', function () {
764
765                    //-------------- scrolls acepts cookies
766                    $('.sticky_top').css({
767                        "-webkit-transform": "translate(-50%, -80px)"
768                    });
769                    setTimeout(function () {
770                        justica.MAIN.CookieBar.createCookie(justica.MAIN.CookieBar.cookieName, true, 5 * 365 /* 5 anos */);
771                        jQuery('.sticky_top').remove();
772                    }, 800);
773
774                });
775            },
776
777            createCookie: function createCookie(name, value, days) {
778                var expires = "";
779                if (days) {
780                    var date = new Date();
781                    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
782                    expires = "; expires=" + date.toUTCString();
783                }
784                document.cookie = name + "=" + value + expires + "; path=/; Secure; SameSite=None";
785            },
786
787            readCookie: function readCookie(name) {
788                var nameEQ = name + "=";
789                var ca = document.cookie.split(';');
790                for (var i = 0; i < ca.length; i++) {
791                    var c = ca[i];
792                    while (c.charAt(0) == ' ') c = c.substring(1, c.length);
793                    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
794                }
795                return null;
796            },
797
798            eraseCookie: function eraseCookie(name) {
799                createCookie(name, "", -1);
800            }
801        },
802
803        Footer: {
804            encontrouOQueProcurava: 'Não',
805            formInfo: {
806                formId: "31cfcd59-685e-444d-b801-d43135d38901",
807                partial: false,
808                score: 0,
809                percentComplete: 100,
810                Timer: {
811                    timeStart: null,
812                    timeEnd: null
813                },
814                timeToComplete: null,
815                timeToBegin: null,
816                timeToSubmit: null,
817                analytics: {
818                    "de272291-bfe8-01f1-82ba-d8111dbdc78f": {
819                        Timer: {
820                            timeStart: null,
821                            timeEnd: null
822                        },
823                        timeToComplete: 0,
824                        complete: true
825                    },
826                    "44920d40-6557-8c07-7e0c-cc89b742a2a3": {
827                        Timer: {
828                            timeStart: null,
829                            timeEnd: null
830                        },
831                        timeToComplete: 4854,
832                        complete: true
833                    }
834                },
835                responses: {
836                    "28b75f91-2db8-4803-eb8e-674dcda108c6": "",
837                    "de272291-bfe8-01f1-82ba-d8111dbdc78f": "",
838                    "44920d40-6557-8c07-7e0c-cc89b742a2a3": ""
839                },
840                url: window.location.protocol + '//' + window.location.hostname,
841
842                setEncontrouOQueProcuravaStartTime: function () {
843                    if (this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].Timer.timeStart == null) {
844                        this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].Timer.timeStart = new Date();
845                    }
846                },
847                setEncontrouOQueProcuravaEndTime: function () {
848                    this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].Timer.timeEnd = new Date();
849                    if (this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].Timer.timeStart == null) {
850                        this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].Timer.timeStart = this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].Timer.timeEnd;
851                    }
852                },
853
854                setOQueProcuravaStartTime: function () {
855                    if (this.analytics["44920d40-6557-8c07-7e0c-cc89b742a2a3"].Timer.timeStart == null) {
856                        this.analytics["44920d40-6557-8c07-7e0c-cc89b742a2a3"].Timer.timeStart = new Date();
857                    }
858                },
859                setOQueProcuravaEndTime: function () {
860                    this.analytics["44920d40-6557-8c07-7e0c-cc89b742a2a3"].Timer.timeEnd = new Date();
861                    if (this.analytics["44920d40-6557-8c07-7e0c-cc89b742a2a3"].Timer.timeStart == null) {
862                        this.analytics["44920d40-6557-8c07-7e0c-cc89b742a2a3"].Timer.timeStart = this.analytics["44920d40-6557-8c07-7e0c-cc89b742a2a3"].Timer.timeEnd;
863                    }
864                },
865
866                resetFormData: function (timeStart) {
867                    this.Timer.timeStart = timeStart || new Date(),
868                        this.Timer.timeEnd = null
869
870                    this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].Timer.timeStart = null,
871                        this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].Timer.timeEnd = null
872
873                    this.analytics["44920d40-6557-8c07-7e0c-cc89b742a2a3"].Timer.timeStart = null,
874                        this.analytics["44920d40-6557-8c07-7e0c-cc89b742a2a3"].Timer.timeEnd = null
875                },
876                getFormDataObject: function (encontrouOQueProcurava, oQueProcurava) {
877                    return {
878                        "formId": this.formId,
879                        "partial": this.partial,
880                        "score": this.score,
881                        "percentComplete": this.percentComplete,
882                        "timeToComplete": this.Timer.timeEnd - this.Timer.timeStart - (this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].Timer.timeStart - this.Timer.timeStart),
883                        "timeToBegin": this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].Timer.timeStart - this.Timer.timeStart,
884                        "timeToSubmit": this.Timer.timeEnd - this.Timer.timeStart,
885                        "analytics": {
886                            "de272291-bfe8-01f1-82ba-d8111dbdc78f": {
887                                "timeToComplete": this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].Timer.timeEnd - this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].Timer.timeStart,
888                                "complete": this.analytics["de272291-bfe8-01f1-82ba-d8111dbdc78f"].complete
889                            },
890                            "44920d40-6557-8c07-7e0c-cc89b742a2a3": {
891                                "timeToComplete": this.analytics["44920d40-6557-8c07-7e0c-cc89b742a2a3"].Timer.timeEnd - this.analytics["44920d40-6557-8c07-7e0c-cc89b742a2a3"].Timer.timeStart,
892                                "complete": this.analytics["44920d40-6557-8c07-7e0c-cc89b742a2a3"].complete
893                            }
894                        },
895                        "responses": {
896                            "28b75f91-2db8-4803-eb8e-674dcda108c6": window.location.href,
897                            "de272291-bfe8-01f1-82ba-d8111dbdc78f": encontrouOQueProcurava,
898                            "44920d40-6557-8c07-7e0c-cc89b742a2a3": oQueProcurava
899                        },
900                        "url": window.location.protocol + '//' + window.location.hostname
901                    }
902                }
903            },
904			emailValido: function(email) {
905				var valid = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/.test(email) && email.length;
906				return valid;
907			},
908            init: function () {
909                var footer = $('footer');
910                var encontrouProcura;
911                $("span.qst").click(function () {
912
913                    if ($(this).text() === 'Sim') {
914                        encontrouProcura = 'true';
915                    } else {
916                        encontrouProcura = 'false';
917                    }
918                    justica.MAIN.Footer.encontrouOQueProcurava = encontrouProcura;
919                });
920
921                //open hidden feedback
922                footer.find('.help_improve .button').on('click', function () {
923                    //contextualised text
924                    if ($(this).hasClass('yes')) {
925                        //SHOW
926                        $('footer').find('label').text(DotNetNuke.Razor.ThemePortalJustica.Footer.feedback_yes_message || 'Obrigado pelo seu contributo');
927                        $('footer').find('#feedback-form').attr("placeholder", DotNetNuke.Razor.ThemePortalJustica.Footer.feedback_yes_placeholder || "Como podemos melhorar?");
928                        jQuery('footer .feedback #button_send').removeClass('no').addClass('yes');
929                    } else {
930                        //SHOW
931                        $('footer').find('label').text(DotNetNuke.Razor.ThemePortalJustica.Footer.feedback_no_message || 'Ajude-nos a melhorar');
932                        $('footer').find('#feedback-form').attr("placeholder", DotNetNuke.Razor.ThemePortalJustica.Footer.feedback_no_placeholder || "Diga-nos o que procurava ou como podemos melhorar esta página");
933                        jQuery('footer .feedback #button_send').removeClass('yes').addClass('no');
934                    }
935
936                    //open
937                    $(this).addClass('open');
938
939                    if (!$(this).hasClass('open')) {
940
941                        footer.find('.hidden_feedback').hide('fast');
942                        footer.find('#feedback-form').hide('fast');
943
944                        footer.find('#feedback-form').val('');
945
946                        footer.find('.#feedback-form').removeClass('open');
947
948
949                    } else {
950                        justica.MAIN.Footer.formInfo.resetFormData(new Date());
951                        //footer.find('.help_improve').css({
952                        //    'opacity': '0',
953                        //    'pointer-events': 'none'
954                        //});
955                        footer.find('.specify, .submit, #feedback-form, .end').css({
956                            'opacity': '1',
957                            'pointer-events': 'auto'
958                        });
959                        footer.find('.help_improve').hide('fast');
960                        footer.find('.end, .specify, .submit, #feedback-form').show();
961                        footer.find('.hidden_feedback').show('fast');
962                        justica.MAIN.Footer.formInfo.setEncontrouOQueProcuravaStartTime();
963
964                    }
965                });
966
967                //close footer
968                footer.find('.end').on('click', function () {
969                    footer.find('.help_improve').css({
970                        'opacity': '1',
971                        'pointer-events': 'auto'
972                    });
973                    footer.find('.hidden_feedback').hide('fast');
974                    footer.find('.help_improve').show('slow');
975                    footer.find('#feedback-form').val('');
976                });
977
978
979                footer.find('#feedback-form').on('click', function () {
980                    justica.MAIN.Footer.formInfo.setEncontrouOQueProcuravaStartTime();
981                    justica.MAIN.Footer.formInfo.setEncontrouOQueProcuravaEndTime();
982                    justica.MAIN.Footer.formInfo.setOQueProcuravaStartTime();
983
984                });
985                //Submit + exit transitions 
986                footer.find('button').on('click', function () {
987                    justica.MAIN.Footer.formInfo.setOQueProcuravaEndTime();
988                    justica.MAIN.Footer.formInfo.Timer.timeEnd = new Date();
989
990                    var footer = $('footer');
991                    var encontrouOQueProcurava = justica.MAIN.Footer.encontrouOQueProcurava;
992                    var oQueProcurava = footer.find('textarea#feedback-form').val();
993
994                    $.ajax({
995                        type: "POST",
996                        url: 'https://dnnapi.com/forms/api/FormResponsesPublic',
997                        data: JSON.stringify(justica.MAIN.Footer.formInfo.getFormDataObject(encontrouOQueProcurava, oQueProcurava)),
998                        success: function (data, status) {
999
1000                            setTimeout(function () {
1001                                footer.find('.specify, .questions, .end').css('opacity', '0');
1002                            }, 0);
1003
1004                            setTimeout(function () {
1005
1006                                $('footer').find('.submit').css({
1007                                    'opacity': '0',
1008                                    'pointer-events': 'none'
1009                                });
1010                            }, 200);
1011
1012                            setTimeout(function () {
1013                                footer.find('.submited').removeClass('open');
1014                                footer.find('.submited').show();
1015                                footer.find('.submited').addClass('open');
1016                            }, 600);
1017
1018                            setTimeout(function () {
1019                                footer.find('.down_icon').removeClass('open');
1020                                //footer.find('.feedback').animate({
1021                                //    height: 0
1022                                //}, {
1023                                //    easing: 'swing',
1024                                //    duration: 300,
1025                                //    complete: function () {
1026                                //        footer.find('.feedback').hide();
1027                                //    }
1028                                //});
1029                                footer.find('#feedback-form').hide('300');
1030                                footer.find('.hidden_feedback').hide('fast');
1031                                footer.find('.end, .specify, .submit, .submited').hide('300');
1032                                footer.find('#feedback-form').val('');
1033                                footer.find('.help_improve').show('300');
1034                            }, 2000);
1035
1036                            //setTimeout(function () {
1037                            //    footer.find('.specify, .questions, .end, .hidden_feedback .line').css('opacity', '1');
1038                            //    footer.find('.submited').removeClass('open');
1039                            //    $('footer').find('button').css({
1040                            //        'opacity': '0',
1041                            //        'pointer-events': 'none'
1042                            //    });
1043                            //}, 2500);
1044                        },
1045                        contentType: "application/json; charset=utf-8",
1046                        dataType: 'json'
1047                    });
1048
1049
1050
1051
1052                });
1053            },
1054
1055        },
1056
1057        Masonry: {
1058            init: function () {
1059                if ($.fn.masonry) {
1060                    $('.masonry-grid').masonry({
1061                        // options
1062                        itemSelector: '.masonry-item',
1063                        columnWidth: ".masonry-item",
1064                        gutter: 0,
1065                        percentPosition: true
1066                    });
1067                }
1068            }
1069        },
1070
1071        UserAuthentication: {
1072            init: function removeChatbot() {
1073                if ($(".justica-cabecalho_autenticacao").length > 0) {
1074
1075
1076                    if (typeof window.ga === 'undefined') {
1077                        // analytics does not exist
1078                    } else {
1079                        if (typeof dataLayer !== 'undefined' && dataLayer != null) {
1080                            dataLayer.push(
1081                                {
1082                                    "event": "userAuthentication",
1083                                    "gtm.elementClasses": true
1084                                });
1085                        }
1086                    }
1087
1088
1089                } else {
1090
1091                    if (typeof window.ga === 'undefined') {
1092                        // analytics does not exist
1093                    } else {
1094                        if (typeof dataLayer !== 'undefined' && dataLayer != null) {
1095                            dataLayer.push(
1096                                {
1097                                    "event": "userAuthentication",
1098                                    "gtm.elementClasses": false
1099                                });
1100                        }
1101                    }
1102                }
1103            }
1104        },
1105
1106        DisplayChatbot: {
1107            init: function removeChatbotInpi() {
1108                if ($(".justica-cabecalho_autenticacao").length > 0) {
1109
1110                    $('body').addClass('authenticated');
1111
1112                    //$('#botDiv').css('display', 'none');
1113
1114                }
1115            }
1116        },
1117
1118        newsletter: {
1119            init: function () {
1120                var newsletterFunction = function () {
1121
1122                    var subscribeFormUrl = $("input#newsletter_input").attr("data-newsletter-url");
1123
1124                    var email = $("input#newsletter_input").val();
1125
1126                    if (email != null && email != undefined && email != '') {
1127                        var newsletterWin = window.open(subscribeFormUrl + email, '_blank');
1128                        newsletterWin.focus();
1129                    }
1130                }
1131
1132                $("#newsletter_link").click(newsletterFunction);
1133                $("#newsletter_input").keyup(function (newsletterFunction) { if (event.keyCode == 13) { $("#newsletter_link").click(); } });
1134            }
1135        },
1136
1137        ImageInject: {
1138            init: function () {
1139                var image = $('.justica-head_servico_img #dnn_Image img , .justica-LP_head_generic.servico_img #dnn_Image img');
1140
1141                if (image.length == 1) {
1142                    $('#dnn_Image').css('background-image', 'url(' + image.attr('src') + ')');
1143                    image.remove();
1144                    $('#dnn_Image').css({ 'height': '100%', 'background-repeat': 'no-repeat', 'background-size': 'cover' });
1145                }
1146            }
1147
1148        },
1149
1150        ManageLanguageDropDown: {
1151            init: function () {
1152                
1153                /*
1154                // ------------- Remover país da lista de linguas
1155                $(".LanguageTrue").parent().remove();
1156                $("#dropdownMenu1").siblings().find(" li a").each(function (key, value) {
1157                    var currentText = value.text;
1158                    value.text = currentText.substring(0, currentText.
1158indexOf("("));
1159                });
1160
1161                $("#dropdownMenu1").each(function (key, value) {
1162                    var currentHtml = $(value).find("span")[0].outerHTML;
1163                    var currentText = $(value).text();
1164
1165                    $(value).text(currentText.substring(0, currentText.indexOf("("))).append(currentHtml);
1166
1167                });
1168
1169                //Adicionar link English INPI
1170                $('.theme--INPI .wrap-sd .dropdown').css('display', 'block');
1171                $('.theme--INPI .navbar .row.top .wrap-sd .dropdown').append('<ul class="dropdown-menu"><li><a href="/Portuguese-Institute-of-Industrial-Property">English</a></li></ul>');
1172
1173                //Mobile INPI
1174                //Por enquanto em mobile não existe opção de troca de idioma
1175                //$('.theme--INPI .navbar .row.top .dropdown_mobile').addClass('showMenu');
1176                //$('.theme--INPI .navbar .row.top .dropdown_mobile').append('<ul class="dropdown-menu"><li><a href=/Portuguese-Institute-of-Industrial-Property">EN</a></li></ul>');
1177                $('.theme--INPI .navbar-mobile .navbar.navbar-default ul.nav.navbar-nav').append('<li class=""><a href="/Portuguese-Institute-of-Industrial-Property">English</a></li>');
1178                */
1179
1180                // ------------- Remover país da lista de linguas
1181                /*$(".LanguageTrue").parent().remove();
1182                $("#dropdownMenu1").siblings().find(" li a").each(function (key, value) {
1183                    var currentText = value.text;
1184                    //value.text = currentText.substring(0, currentText.indexOf("("));
1185                });
1186                $("#dropdownMenu1").each(function (key, value) {
1187                    var currentHtml = $(value).find("span")[0].outerHTML;
1188                    var currentText = $(value).text();
1189                    //$(value).text(currentText.substring(0, currentText.indexOf("("))).append(currentHtml);
1190                }).promise().done(function () {
1191                    $('.wrap-sd .dropdown').css('display', 'block');
1192                    });
1193                */
1194                $("#languageSelector").children().each(function (key, value) {
1195                    var currentText = value.text;
1196                    value.text = currentText.substring(0, currentText.indexOf("("));
1197                }).promise().done(function () {
1198                    $('.wrap-sd .dropdown').css('visibility', 'visible');
1199                    //$('.wrap-sd .dropdown').css('style', 'block');
1200                    });
1201
1202                $("#languageSelectorMobile").children().each(function (key, value) {
1203                    var currentText = $(value).find("a")[0].text;
1204                    $(value).find("a")[0].text = currentText.substring(0, currentText.indexOf("("));
1205                    $(value).addClass("showTablet hidebiggerthantablet_1");
1206
1207                    $("ul.nav.navbar-nav").append(value);
1208                });
1209
1210                $("#languageSelectorMobile").remove();
1211            }
1212        }
1213    }
1214})();
1215
1216$(document).ready(function () {
1217    justica.MAIN.init();
1218});

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.