|
|
| Line 109: |
Line 109: |
|
| |
|
| }() ); | | }() ); |
| /* ════════════════════════════════════════════════ | | /* ════════════════════════════════════════════════════════════════ |
| Grantha — Site chrome (hide wiki UI, inject top bar) | | Grantha — MediaWiki:Common.js |
| Edit at: yourdomain.com/wiki/MediaWiki:Common.js
| | Builds the top bar DOM on NS_MAIN pages. |
| ════════════════════════════════════════════════ */ | | All styles (chrome-hiding + top bar) live in MediaWiki:Common.css. |
| | ════════════════════════════════════════════════════════════════ */ |
|
| |
|
| ( function () { | | ( function () { |
| 'use strict'; | | 'use strict'; |
|
| |
|
| /* Only run on NS_MAIN pages, skip Special pages */ | | /* Only run on NS_MAIN pages */ |
| if ( mw.config.get( 'wgNamespaceNumber' ) !== 0 ) return; | | if ( mw.config.get( 'wgNamespaceNumber' ) !== 0 ) return; |
|
| |
|
| /* ── 1. Inject hide-chrome CSS immediately ── */
| |
| var css = [
| |
| /* Sidebar */
| |
| '#mw-navigation,#mw-panel,.mw-sidebar,.vector-sidebar-container,',
| |
| '.vector-sidebar-container-no-toc,#p-logo,.mw-portlet-logo{display:none!important}',
| |
| /* Page action tabs */
| |
| '#p-views,#p-cactions,.mw-portlet-views,.vector-page-tools,',
| |
| '.vector-page-tools-landmark,#ca-edit,#ca-ve-edit,#ca-history,',
| |
| '#ca-talk,#ca-nstab-main,.page-actions-menu,',
| |
| '.vector-page-titlebar-toc{display:none!important}',
| |
| /* User/personal tools */
| |
| '#p-personal,.vector-user-links,.vector-user-menu,',
| |
| '#pt-createaccount,#pt-login,#pt-logout,',
| |
| '.mw-portlet-personal,.vector-client-prefs-landmark{display:none!important}',
| |
| /* Header search */
| |
| '#p-search,.vector-search-box,.mw-header .cdx-search-input{display:none!important}',
| |
| /* Top header strip */
| |
| '.vector-header-start,.vector-header-end,.mw-header{display:none!important}',
| |
| /* Footer */
| |
| '#footer,.mw-footer,.vector-footer,.page-footer{display:none!important}',
| |
| /* Misc */
| |
| '#siteNotice,#localNotice,.usermessage,#catlinks,.catlinks,',
| |
| '.printfooter,.mw-indicators{display:none!important}',
| |
| /* Remove sidebar margin, full-width content */
| |
| '#mw-content-text,#content,.mw-body,.mw-body-content,',
| |
| '.vector-body,#bodyContent{margin-left:0!important;padding-left:0!important}',
| |
| '#content,#mw-content-container,.mw-page-container,',
| |
| '.vector-page-container,.mw-body{max-width:100%!important;padding:0!important;margin:0!important}',
| |
| '#mw-content-text,#bodyContent{margin-top:0!important}',
| |
| /* Top bar */
| |
| '#grantha-topbar{',
| |
| ' position:fixed;top:0;left:0;right:0;z-index:10000;height:50px;',
| |
| ' background:#1a2e40;display:flex;align-items:center;',
| |
| ' justify-content:space-between;padding:0 24px;',
| |
| ' box-shadow:0 1px 0 rgba(255,255,255,0.06);',
| |
| ' font-family:system-ui,sans-serif;',
| |
| '}',
| |
| '#grantha-topbar .gt-brand{',
| |
| ' display:flex;align-items:center;gap:10px;text-decoration:none;',
| |
| '}',
| |
| '#grantha-topbar .gt-favicon{',
| |
| ' width:22px;height:22px;border-radius:4px;object-fit:contain;',
| |
| ' filter:brightness(0) invert(1);opacity:.9;',
| |
| '}',
| |
| '#grantha-topbar .gt-name{',
| |
| ' color:#fff;font-size:15px;font-weight:700;letter-spacing:-.01em;',
| |
| '}',
| |
| '#grantha-topbar .gt-right{display:flex;align-items:center;gap:10px;}',
| |
| '#grantha-topbar .gt-btn{',
| |
| ' font-size:12.5px;padding:6px 16px;border-radius:20px;',
| |
| ' border:1.5px solid rgba(255,255,255,0.3);',
| |
| ' background:rgba(255,255,255,0.08);color:#fff;',
| |
| ' cursor:pointer;font-family:inherit;font-weight:600;',
| |
| ' transition:background .15s,border-color .15s;white-space:nowrap;',
| |
| '}',
| |
| '#grantha-topbar .gt-btn:hover{',
| |
| ' background:rgba(255,255,255,0.18);border-color:rgba(255,255,255,0.55);',
| |
| '}',
| |
| 'body{padding-top:50px!important}',
| |
| '@media print{#grantha-topbar{display:none!important}body{padding-top:0!important}}'
| |
| ].join( '' );
| |
|
| |
| if ( !document.getElementById( 'grantha-chrome-css' ) ) {
| |
| var style = document.createElement( 'style' );
| |
| style.id = 'grantha-chrome-css';
| |
| style.textContent = css;
| |
| ( document.head || document.documentElement ).appendChild( style );
| |
| }
| |
|
| |
| /* ── 2. Build the top bar ── */
| |
| mw.hook( 'wikipage.content' ).add( function () { | | mw.hook( 'wikipage.content' ).add( function () { |
| if ( document.getElementById( 'grantha-topbar' ) ) return; | | if ( document.getElementById( 'grantha-topbar' ) ) return; |
|
| |
|
| /* Hide topbar on edit pages — the editor toolbar takes over */ | | /* Hide top bar on edit pages — the editor toolbar takes over */ |
| var action = mw.config.get( 'wgAction' ); | | var action = mw.config.get( 'wgAction' ); |
| if ( action === 'edit' || action === 'submit' ) return; | | if ( action === 'edit' || action === 'submit' ) return; |
| Line 210: |
Line 141: |
| '</a>' + | | '</a>' + |
| '<div class="gt-right">' + | | '<div class="gt-right">' + |
| ' <button class="gt-btn" id="gt-newdoc">✚ New Document</button>' + | | ' <button class="gt-btn" id="gt-newdoc">\u271a New Document</button>' + |
| '</div>'; | | '</div>'; |
|
| |
|
| Line 216: |
Line 147: |
|
| |
|
| document.getElementById( 'gt-newdoc' ).addEventListener( 'click', function () { | | document.getElementById( 'gt-newdoc' ).addEventListener( 'click', function () { |
| /* NewPageDialog is provided by the Editor extension */
| |
| if ( window.NewPageDialog ) NewPageDialog.show(); | | if ( window.NewPageDialog ) NewPageDialog.show(); |
| } ); | | } ); |