|
|
| (6 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| <templatestyles src="Template:18PlusDisclaimer/styles.css" /> | | <templatestyles src="Template:18PlusDisclaimer/styles.css" /> |
|
| |
|
| <!-- the overlay itself -->
| |
| {{#tag:html| | | {{#tag:html| |
| <div id="ageDisclaimerOverlay" class="age-overlay" style="display:none"> | | <script src="https://www.gamebrew.org/images/misc/assets/js/Disclaimer.js"></script> |
| <div class="age-blur"></div>
| | <script src="https://www.gamebrew.org/images/misc/assets/js/common.js"></script> |
| <div class="age-popup slide-down">
| |
| <h2>You must be 18+ to view this content</h2>
| |
| <p>This page may contain content intended for mature audiences only.<br>Please confirm that you are 18 years of age or older.</p>
| |
| <div class="btn-group">
| |
| <button id="acceptDisclaimer">I am 18 or older</button>
| |
| <button id="declineDisclaimer">Leave this page</button>
| |
| </div>
| |
| </div>
| |
| </div>
| |
| }} | | }} |
|
| |
| <!-- the behavior, loaded safely as JS -->
| |
| {{#tag:script|
| |
| (function($, mw) {
| |
| // once mw.user and mw.util are available…
| |
| mw.loader.using(['mediawiki.user', 'mediawiki.util']).then(function() {
| |
| var overlay = $('#ageDisclaimerOverlay'),
| |
| popup = overlay.find('.age-popup'),
| |
| isAnon = mw.user.isAnon(),
| |
| cookieConfirmed = document.cookie.split('; ').some(function(c){ return c.trim()==='ageConfirmed=true'; });
| |
|
| |
| // show to everyone on first visit, and force-show again for logged‑in users
| |
| if (!cookieConfirmed || !isAnon) {
| |
| overlay.css('display','flex');
| |
| $('body').css('overflow','hidden');
| |
| // trigger slide‑in
| |
| requestAnimationFrame(function(){ popup.addClass('slide-active'); });
| |
| }
| |
|
| |
| $('#acceptDisclaimer').on('click', function() {
| |
| // set 30‑day cookie
| |
| document.cookie = 'ageConfirmed=true;max-age=' + (30*24*60*60) + ';path=/';
| |
| overlay.hide();
| |
| $('body').css('overflow','');
| |
| });
| |
|
| |
| $('#declineDisclaimer').on('click', function() {
| |
| window.location.href = mw.util.getUrl('Main_Page');
| |
| });
| |
| });
| |
| })(jQuery, mw);
| |
| | type="text/javascript" }}
| |