summaryrefslogtreecommitdiff
path: root/lib/grappelli/media/js/documentation.js
blob: b00c1200d9bb1ea7179c7dca20a05c2595fca6b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(function($) {
    $(document).ready(function(){
        // Correct the position of anchors (because "#header" & "#breadcrumbs" have a "position:fixed")
        $('.table-of-contents a').click(function(){
            var myReference = ".rte " + $(this).attr('href');
            // if collapsible
            var myParentCollapsible = $(myReference).parent().parent();
            if ($(myParentCollapsible).hasClass('closed')){
                $(myParentCollapsible).toggleClass('open').toggleClass('closed');
            }
            // anchor offset
            var targetOffset = $(myReference).offset().top;
            $('html,body').scrollTop(targetOffset - 60);
            return(false);
        })
        // Remove emtpy elements: wrkaround for problem reported in django-ticket #11817
        $('.rte h4:empty').remove();
        $('.rte p:empty').remove();
        $('.rte hr').remove();
    });
})(django.jQuery);