MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 283: Line 283:
     var nav = document.createElement( 'div' );
     var nav = document.createElement( 'div' );
     nav.id = 'gr-toc-doc-nav';
     nav.id = 'gr-toc-doc-nav';
     nav.setAttribute( 'style', [
     nav.setAttribute( 'class', 'toc-nav-links');
      'display:flex', 'gap:6px', 'padding:5px 8px 6px',
      'border-bottom:1px solid var(--border-color-base,#dcc9a8)',
      'margin-bottom:4px', 'flex-wrap:wrap',
    ].join( ';' ) );


     var base = [
     var base = [
Line 296: Line 292:
     ].join( ';' );
     ].join( ';' );


     function makeBtn( href, label, color, bg ) {
     function makeBtn( href, label ) {
       var a = document.createElement( 'a' );
       var a = document.createElement( 'a' );
       a.href = href;
       a.href = href;
       a.textContent = label;
       a.textContent = label;
       a.setAttribute( 'style', base + ';color:' + color + ';background:' + bg + ';' );
       a.setAttribute( 'class', 'toc-nav-link-item');
       a.addEventListener( 'mouseover', function () { this.style.opacity = '0.72'; } );
       a.addEventListener( 'mouseover', function () { this.style.opacity = '0.72'; } );
       a.addEventListener( 'mouseout',  function () { this.style.opacity = '1';    } );
       a.addEventListener( 'mouseout',  function () { this.style.opacity = '1';    } );
Line 307: Line 303:


     /* Bhashya page: show मूलम् (→ /Moola filtered view) */
     /* Bhashya page: show मूलम् (→ /Moola filtered view) */
     if ( showMoolaPage ) nav.appendChild( makeBtn( moolaPageUrl, 'मूलम्',  '#b04b00', '#fff3e0' ) );
     if ( showMoolaPage ) nav.appendChild( makeBtn( moolaPageUrl, 'मूलम्' ) );
     /* Teeka page: show मूल (→ primary bhashya) */
     /* Teeka page: show मूल (→ primary bhashya) */
     if ( showMoolaBack ) nav.appendChild( makeBtn( moolaUrl,    'मूल',    '#b04b00', '#fff3e0' ) );
     if ( showMoolaBack ) nav.appendChild( makeBtn( moolaUrl,    'मूल' ) );
     /* Either page type: show उल्लेख when available */
     /* Either page type: show उल्लेख when available */
     if ( showUllekha  ) nav.appendChild( makeBtn( ullekhaUrl,  'उल्लेख', '#1a5f8a', '#e8f4fc' ) );
     if ( showUllekha  ) nav.appendChild( makeBtn( ullekhaUrl,  'उल्लेख') );


     var tocContents = toc.querySelector( '.vector-toc-contents' );
     var tocContents = toc.querySelector( '.vector-toc-contents' );