1 /* Make button to make fixed toc */
4 var width, contentHeaderOffset, indexButton, navHeight, id;
5 width = $( window ).width();
6 if ( $( '#toc' ).html() && width > 1649 ) {
7 contentHeaderOffset = $( '.liberty-content-header' ).offset();
8 indexButton = document.createElement( 'button' );
9 indexButton.id = 'fixed-toc-button';
10 indexButton.type = 'button';
11 indexButton.className = 'btn btn-primary';
12 indexButton.innerHTML = '<span class="fa fa-list" aria-hidden="true"></span>';
13 indexButton.style.position = 'fixed';
14 indexButton.style.top = contentHeaderOffset.top + 'px';
15 indexButton.style.left = ( contentHeaderOffset.left - 47 - 15 ) + 'px';
16 window.damezuma = { doc: null };
17 $( indexButton ).click( function () {
18 $( indexButton ).fadeOut( 200 );
19 if ( !window.damezuma.doc ) {
20 window.damezuma.doc = $( '#toc' ).clone();
21 $( document.body ).append( window.damezuma.doc );
22 $( window.damezuma.doc ).css( {
26 'background-color': '#f5f8fa',
27 'border-right': '1px solid #e1e8ed',
36 window.damezuma.doc[ 0 ].id = 'fixed-toc';
37 window.damezuma.doc.fadeIn( 200 );
38 $( '#fixed-toc > .togglelink' ).click( function () {
39 $( '#fixed-toc-button' ).fadeIn( 200 );
40 $( window.damezuma.doc ).remove();
41 window.damezuma.doc = null;
45 /* Left toc click process */
46 navHeight = $( '.nav-wrapper' ).height();
47 $( '#fixed-toc ul li > a' ).click( function () {
48 if ( $( this ).attr( 'href' )[ 0 ] === '#' ) {
49 id = String( $( this ).attr( 'href' ) );
50 if ( id.indexOf( '.' ) !== -1 ) {
51 id = document.getElementById( id.replace( '#', '' ) );
53 $( 'html,body' ).animate( {
54 scrollTop: ( $( id ).offset().top - navHeight - 10 )
59 /* Left toc click process End */
62 $( document.body ).append( indexButton );