talos

Форк
0
49 строк · 2.1 Кб
1
/*
2
 * Copyright 2018 Google LLC
3

4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7

8
    https://www.apache.org/licenses/LICENSE-2.0
9

10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16

17
(function ($) {
18
    'use strict';
19

20
    // Headers' anchor link that shows on hover
21
    $(function () {
22
        // append anchor links to headings in markdown.
23
        var article = document.getElementsByTagName('main')[0];
24
        if (!article) {
25
            return;
26
        }
27
        var headings = article.querySelectorAll('h1, h2, h3, h4, h5, h6');
28
        headings.forEach(function (heading) {
29
            if (heading.id) {
30
                var a = document.createElement('a');
31
                // set visibility: hidden, not display: none to avoid layout change
32
                a.style.visibility = 'hidden';
33
                // [a11y] hide this from screen readers, etc..
34
                a.setAttribute('aria-hidden', 'true');
35
                // material insert_link icon in svg format
36
                a.innerHTML = ' <svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>';
37
                a.href = '#' + heading.id;
38
                heading.insertAdjacentElement('beforeend', a);
39
                heading.addEventListener('mouseenter', function () {
40
                    a.style.visibility = 'initial';
41
                });
42
                heading.addEventListener('mouseleave', function () {
43
                    a.style.visibility = 'hidden';
44
                });
45
            }
46
        });
47
    });
48

49
}(jQuery));
50

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.