MediaWiki:Common.js: Difference between revisions
From Fischer Diaries
Administator (talk | contribs) (Created page with "→Any JavaScript here will be loaded for all users on every page load.: $(document).ready(function() { $(document).keydown(function(e) { switch(e.which) { case...") |
Administator (talk | contribs) mNo edit summary |
||
Line 19: | Line 19: | ||
} | } | ||
}); | }); | ||
if ($('a[rel="prev"]').length > 0 || $('a[rel="next"]').length > 0) { | |||
// check cookie | |||
var visited = $.cookie("display-navigation") | |||
if (visited == null) { | |||
$('#footer').append('<div id="navigationHelp" class="modal" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-body"><p>You can navigate between dates by hitting left and right arrows.</p></div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button></div></div></div></div>'); | |||
$('#navigationHelp').modal('show'); | |||
} | |||
// set cookie | |||
$.cookie('display-navigation', 'yes', { expires: 1, path: '/' }); | |||
} | |||
}); | }); |
Revision as of 20:36, 28 March 2020
/* Any JavaScript here will be loaded for all users on every page load. */ $(document).ready(function() { $(document).keydown(function(e) { switch(e.which) { case 37: // left if ($('a[rel="prev"]').length > 0) { $('a[rel="prev"]')[0].click(); e.preventDefault(); // prevent the default action (scroll / move caret) } break; case 39: // right if ($('a[rel="next"]').length > 0) { $('a[rel="next"]')[0].click(); e.preventDefault(); // prevent the default action (scroll / move caret) } break; default: return; // exit this handler for other keys } }); if ($('a[rel="prev"]').length > 0 || $('a[rel="next"]').length > 0) { // check cookie var visited = $.cookie("display-navigation") if (visited == null) { $('#footer').append('<div id="navigationHelp" class="modal" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-body"><p>You can navigate between dates by hitting left and right arrows.</p></div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button></div></div></div></div>'); $('#navigationHelp').modal('show'); } // set cookie $.cookie('display-navigation', 'yes', { expires: 1, path: '/' }); } });