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 253: | Baris 253: | ||
setTimeout(function() { $('body').css('opacity', '1'); }, 100); | setTimeout(function() { $('body').css('opacity', '1'); }, 100); | ||
}); | }); | ||
/* 1. Integrasi Progress Ring pada Tombol Back to Top */ | |||
$(document).ready(function() { | |||
// Kita modifikasi tombol back to top bawaan atau yang sudah ada | |||
var $btt = $('.back-to-top, #mw-mf-back-to-top'); | |||
if ($btt.length) { | |||
$btt.css({ | |||
'background': 'transparent', | |||
'box-shadow': 'none', | |||
'display': 'flex', | |||
'align-items': 'center', | |||
'justify-content:': 'center' | |||
}); | |||
// Masukkan elemen SVG lingkaran | |||
var svgRing = '<svg width="50" height="50" style="position:absolute; transform: rotate(-90deg); pointer-events:none;">' + | |||
'<circle cx="25" cy="25" r="22" stroke="#eee" stroke-width="3" fill="white" />' + | |||
'<circle id="btt-progress" cx="25" cy="25" r="22" stroke="#36c" stroke-width="3" fill="none" ' + | |||
'stroke-dasharray="138.23" stroke-dashoffset="138.23" style="transition: stroke-dashoffset 0.1s linear;" />' + | |||
'</svg>'; | |||
$btt.prepend(svgRing); | |||
$btt.find('span, i, .mw-ui-icon').css({'z-index': '2', 'position': 'relative'}); | |||
$(window).scroll(function() { | |||
var scrollPercent = ($(window).scrollTop() / ($(document).height() - $(window).height())) * 100; | |||
var offset = 138.23 - (scrollPercent / 100) * 138.23; | |||
$('#btt-progress').css('stroke-dashoffset', offset); | |||
}); | |||
} | |||
}); | |||
/* 2. Auto-Source on Copy (Kredit Otomatis) */ | |||
document.addEventListener('copy', function(e) { | |||
var selection = window.getSelection(); | |||
if (selection.toString().length > 1) { // Hanya aktif kalau copy lebih dari 50 karakter | |||
var body_element = document.getElementsByTagName('body')[0]; | |||
var newdiv = document.createElement('div'); | |||
newdiv.style.position = 'absolute'; | |||
newdiv.style.left = '-99999px'; | |||
body_element.appendChild(newdiv); | |||
newdiv.innerHTML = selection + '<br /><br />Sumber: Mippedia - ' + document.title + '<br />Link: ' + window.location.href; | |||
selection.selectAllChildren(newdiv); | |||
window.setTimeout(function() { | |||
body_element.removeChild(newdiv); | |||
}, 0); | |||
} | |||
}); | |||
/* 3. Smooth Selection (Biar Highlight Teks Berwarna Biru Mippedia) */ | |||
$("<style>").prop("type", "text/css").html(` | |||
::selection { background: #36c; color: #fff; } | |||
::-moz-selection { background: #36c; color: #fff; } | |||
`).appendTo("head"); | |||