PageSourceSearch

https://help.anthology.com/blackboard/student/js/html5-2.js

js anthology.com collected 2026-09-24 08:25:52 UTC 6,099 bytes, 180 lines download raw bytes

1$(document).ready(function () {
2
3    //If not using standalone toc, we still need to call all the functions in toc ready, otherwise it's done when creating the standalone toc
4    var tocmeta = document.querySelector('meta[name="tocstandalone"]');
5    if(tocmeta){
6        var tocstandalone = document.querySelector('meta[name="tocstandalone"]').content;
7        if(tocstandalone == 'no'){
8            $(document).trigger('toc.ready');
9        }
10    }
11
12    /*If a link target is a hidden accordion, first display it:
13    =========*/
14    var url = window.location.href;
15    var hash = window.location.hash;
16    /*From another page:*/
17    displayAccordionTarget(hash);
18
19    /*Same page*/
20    $(document.body).on('click', 'a.xref, a.topic-link, a.link, .aa-dropdown-menu a, #search-result-wrapper a', function (event) {
21        var id = this.hash;
22        displayAccordionTarget(id);
23    });
24
25    /* Adjusting position in view for internal page toc links */
26    $(document.body).on('click', '.section-nav-container a', function (e) {
27        var clickedhref = $(this).attr('href');
28        var id = this.hash;
29        displayAccordionTarget(id);
30        $(clickedhref).scrollView();
31        e.preventDefault();
32    });
33    /*=========*/
34
35    //Bootstrap popovers for glossterms
36    $('[data-toggle="popover"]').popover({
37        animation: "fade",
38        delay: {
39            show: "200",
40            hide: "100"
41        },
42        trigger: "hover",
43        placement: "auto bottom",
44        container: 'body',
45        html: true,
46        content: function () {
47            var clone = $('.glossary-definitions ' + $(this).data('popover-content')).first().clone(true).removeClass('hide');
48            return clone;
49        }
50    });
51
52    var $searchform = $(".tool-search-form");
53    
54    /* Make search icon focusable in theme 2 */
55    var $searchIcon = $('.toolbar .tool-search > i.fa-search');
56    if ($searchIcon.length && theme == '2') {
57        $searchIcon.off('focus.searchA11y');
58        $searchIcon.on('focus.searchA11y', function () {
59            $(this).trigger('click');
60        });
61    }
62    
63    $(".toolbar .tool-search > i").click(function() {
64        $searchform.show().fadeIn(100, function() {
65            $(".tool-search-form .search-field").select();
66            $(".top-nav-menu").fadeOut(100);
67        });
68    });
69    $searchform.focusout(function() {
70        $searchform.fadeOut(100, function() {
71            $(this).hide();
72            $(".top-nav-menu").fadeIn(100);
73        });
74    });
75
76    /**
77     * JM: This snippet will add an 'oncopy' eventlistener to all programlistings that are usign callouts.
78     * This listener will clean out any callout elements before copying and after the copying restore the
79     * callouts.
80     */
81    $(".programlisting").has(".co").on("copy",
82    function () {
83        // Save selection
84        var sel = window.getSelection();
85        var range;
86        var startClass = 'start-selection';
87        var endClass = 'end-selection';
88        if (sel.getRangeAt && sel.rangeCount) {
89            var savedRange = window.getSelection().getRangeAt(0);
90            // Save start
91            range = savedRange.cloneRange();
92            range.collapse(true);
93            var $start = $('<span></span>').addClass(startClass);
94            range.insertNode($start[0]);
95            // Save end
96            range = savedRange.cloneRange();
97            range.collapse(false);
98            var $end = $('<span></span>').addClass(endClass);
99            range.insertNode($end[0]);
100        }
101        var el = $(this);
102        var innerHtml = el.html();
103        el.find('.co').remove();
104        setTimeout(function() {
105            el.children().remove();
106            el.html(innerHtml);
107            // Restore selection
108            sel.removeAllRanges();
109            range.setStartBefore($('.'+startClass)[0]);
110            range.setEndBefore($('.'+endClass)[0]);
111            sel.addRange(range);
112
113            $('.'+startClass).remove();
114            $('.'+endClass).remove();
115        });
116    }
117    );
118
119	initChecklist();
120});
121
122/* Adjusting position in view for internal page toc links. Ajax version handles this elsewhere */
123$.fn.scrollView = function () {
124  return this.each(function () {
125    $('html, body').animate({
126      scrollTop: $(this).offset().top - 80
127    }, 0);
128  });
129};
130
131$(document).on('toc.ready', function () {
132
133    $("aside ul.toc a").click(function (e) {
134        //Only for internal sections:
135        var r = new RegExp('#');
136        if (r.test($(this).attr('href'))) {
137            $("aside ul.toc a").parent().removeClass("active").removeClass("opened");
138            $(this).parent().addClass("active");
139            $(this).parents("li").addClass("opened");
140        }
141    });
142
143    setActiveTocline();
144    chunkedPrevNext();
145    buildSectionToc();
146    if(useanchorlinks){
147        setAnchors();
148    }
149
150    if (theme == '3' || theme == '3b') {
151        $("aside ul.toc").attr({
152            "data-spy": "affix", "data-offset-top": "157", "data-offset-bottom": "50"
153        });
154    }
155
156    /* Prevents double scroll bar behaviour if viewport width changes */
157    if (theme == '3c' || theme == '3d') {
158        $('.navbar-toggle').click(function() {
159            $('body').toggleClass('overflow-hidden');
160        });
161    }
162
163    /*Swagger embed needs the nav arrow for dynamically loaded sub toc:*/
164    var glyphicon = "<span class='glyphicon'></span>";
165    $('ul.nav-site-sidebar .swagger-topic').append(glyphicon);
166
167    /*Collapse sections (and make non-clickable topic headings act in the same way as glyphicons):*/
168    if (collapseTocSectionOnLinkTitleClick) {
169        $(".nav-site-sidebar a:not(.topichead) .glyphicon, .nav-site-sidebar a.topichead, .nav-site-sidebar li.active.opened>a").click(function (e) {
170            e.preventDefault();
171            $(this).closest("li").toggleClass("opened");
172        });
173    }else {
174        $(".nav-site-sidebar a:not(.topichead) .glyphicon, .nav-site-sidebar a.topichead").click(function (e) {
175            e.preventDefault();
176            $(this).closest("li").toggleClass("opened");
177        });
178    }
179    
180});

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.