MediaWiki:Common.js: Perbedaan antara revisi
Tidak ada ringkasan suntingan Tanda: Suntingan perangkat seluler Suntingan peramban seluler |
Tidak ada ringkasan suntingan Tanda: Suntingan perangkat seluler Suntingan peramban seluler |
||
| Baris 164: | Baris 164: | ||
}); | }); | ||
/* 3. Anti-Ghosting pada Link Kosong (Redlinks) */ | /* 3. Anti-Ghosting pada Link Kosong (Redlinks) */ | ||
| Baris 230: | Baris 175: | ||
}); | }); | ||
/* | /* 1. Navigasi Bab Melayang (Quick Jump) */ | ||
$(document).ready(function() { | |||
if (mw.config.get('wgIsArticle') && $('#toc').length) { | |||
var $quickNav = $('<div id="quick-nav" style="position:fixed; bottom:140px; right:20px; width:45px; height:45px; background:#36c; color:#fff; border-radius:50%; display:flex; align-items:center; justify-content:center; z-index:9996; box-shadow:0 4px 10px rgba(0,0,0,0.3); cursor:pointer; font-weight:bold; font-size:18px;">≡</div>'); | |||
$('body').append($quickNav); | |||
$quickNav.click(function() { | |||
var $toc = $('#toc ul').first().clone(); | |||
var $modal = $('<div id="nav-modal" style="position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.8); z-index:20001; display:flex; align-items:center; justify-content:center;">' + | |||
'<div style="background:#fff; width:85%; max-height:70%; overflow-y:auto; border-radius:15px; padding:20px; position:relative;">' + | |||
'<div id="close-nav" style="position:absolute; top:10px; right:15px; font-size:24px; color:#333;">×</div>' + | |||
'<h3 style="margin-top:0; color:#36c;">Lompat ke Bagian:</h3>' + | |||
'<div id="nav-list"></div>' + | |||
'</div></div>'); | |||
$('body').append($modal); | |||
$modal.find('#nav-list').append($toc); | |||
// Style link di dalam modal biar enak diklik jempol | |||
$modal.find('a').css({'display':'block', 'padding':'10px 0', 'color':'#333', 'text-decoration':'none', 'border-bottom':'1px solid #eee'}); | |||
$('#close-nav, #nav-modal').click(function(e) { | |||
if (e.target !== this && e.target.id !== 'close-nav') return; | |||
$modal.remove(); | |||
}); | |||
}); | |||
} | |||
}); | |||
/* 2. Auto-Night Shift (Berdasarkan Jam Lokal) */ | |||
$(document).ready(function() { | $(document).ready(function() { | ||
var hour = new Date().getHours(); | |||
if ( | if (hour >= 21 || hour < 6) { // Jam 9 malem sampe 6 pagi | ||
$("<style id='night-shift'>").prop("type", "text/css").html(` | |||
body::after { | |||
content: ""; | |||
position: fixed; | |||
top: 0; left: 0; | |||
width: 100vw; height: 100vh; | |||
background: rgba(255, 165, 0, 0.05); /* Filter orange tipis */ | |||
pointer-events: none; | |||
z-index: 99999; | |||
} | } | ||
`).appendTo("head"); | |||
} | } | ||
}); | }); | ||
/* | /* 3. Smooth Fade-In saat Ganti Halaman */ | ||
$( | $(document).ready(function() { | ||
$('body').css({'opacity': '0', 'transition': 'opacity 0.5s ease'}); | |||
setTimeout(function() { $('body').css('opacity', '1'); }, 100); | |||
}); | |||