|
|
| Line 107: |
Line 107: |
| } | | } |
| } | | } |
|
| |
| }() );
| |
| /* ════════════════════════════════════════════════════════════════
| |
| Grantha — MediaWiki:Common.js
| |
| Builds the top bar DOM on NS_MAIN pages.
| |
| All styles (chrome-hiding + top bar) live in MediaWiki:Common.css.
| |
| ════════════════════════════════════════════════════════════════ */
| |
|
| |
| ( function () {
| |
| 'use strict';
| |
|
| |
| /* Only run on NS_MAIN pages */
| |
| if ( mw.config.get( 'wgNamespaceNumber' ) !== 0 ) return;
| |
|
| |
| mw.hook( 'wikipage.content' ).add( function () {
| |
| if ( document.getElementById( 'grantha-topbar' ) ) return;
| |
|
| |
| /* Hide top bar on edit pages — the editor toolbar takes over */
| |
| var action = mw.config.get( 'wgAction' );
| |
| if ( action === 'edit' || action === 'submit' ) return;
| |
|
| |
| var mainPage = ( mw.config.get( 'wgArticlePath' ) || '/wiki/$1' )
| |
| .replace( '$1', encodeURIComponent(
| |
| mw.config.get( 'wgMainPageTitle' ) || 'Main_Page'
| |
| ) );
| |
|
| |
| var bar = document.createElement( 'div' );
| |
| bar.id = 'grantha-topbar';
| |
| bar.innerHTML =
| |
| '<a class="gt-brand" href="' + mainPage + '">' +
| |
| ' <img class="gt-favicon" src="/favicon.ico" alt="" />' +
| |
| ' <span class="gt-name">Grantha</span>' +
| |
| '</a>' +
| |
| '<div class="gt-right">' +
| |
| ' <button class="gt-btn" id="gt-newdoc">\u271a New Document</button>' +
| |
| '</div>';
| |
|
| |
| document.body.prepend( bar );
| |
|
| |
| document.getElementById( 'gt-newdoc' ).addEventListener( 'click', function () {
| |
| if ( window.NewPageDialog ) NewPageDialog.show();
| |
| } );
| |
| } );
| |
|
| |
|
| }() ); | | }() ); |