Difference between revisions of "MediaWiki:Common.js"
From Drawn to Life Wiki
(Blanked the page) Tag: Blanking |
(Drag to scroll for template levelmap) |
||
| Line 1: | Line 1: | ||
| − | + | // Drag to scroll for template levelmap | |
| + | $(document).ready(function () { | ||
| + | $('.TEMPLATE-LevelMap').mousedown(function (event) { | ||
| + | $(this) | ||
| + | .data('down', true) | ||
| + | .data('x', event.clientX) | ||
| + | .data('scrollLeft', this.scrollLeft); | ||
| + | |||
| + | return false; | ||
| + | }).mouseup(function (event) { | ||
| + | $(this).data('down', false); | ||
| + | }).mousemove(function (event) { | ||
| + | if ($(this).data('down') == true) { | ||
| + | this.scrollLeft = $(this).data('scrollLeft') + $(this).data('x') - event.clientX; | ||
| + | } | ||
| + | }).mousewheel(function (event, delta) { | ||
| + | this.scrollLeft -= (delta * 30); | ||
| + | }).css({ | ||
| + | 'overflow' : 'hidden', | ||
| + | 'cursor' : '-moz-grab' | ||
| + | }); | ||
| + | }); | ||
| + | |||
| + | $(window).mouseout(function (event) { | ||
| + | if ($('.TEMPLATE-LevelMap').data('down')) { | ||
| + | try { | ||
| + | if (event.originalTarget.nodeName == 'BODY' || event.originalTarget.nodeName == 'HTML') { | ||
| + | $('.TEMPLATE-LevelMap').data('down', false); | ||
| + | } | ||
| + | } catch (e) {} | ||
| + | } | ||
| + | }); | ||
Revision as of 18:52, 28 June 2022
// Drag to scroll for template levelmap
$(document).ready(function () {
$('.TEMPLATE-LevelMap').mousedown(function (event) {
$(this)
.data('down', true)
.data('x', event.clientX)
.data('scrollLeft', this.scrollLeft);
return false;
}).mouseup(function (event) {
$(this).data('down', false);
}).mousemove(function (event) {
if ($(this).data('down') == true) {
this.scrollLeft = $(this).data('scrollLeft') + $(this).data('x') - event.clientX;
}
}).mousewheel(function (event, delta) {
this.scrollLeft -= (delta * 30);
}).css({
'overflow' : 'hidden',
'cursor' : '-moz-grab'
});
});
$(window).mouseout(function (event) {
if ($('.TEMPLATE-LevelMap').data('down')) {
try {
if (event.originalTarget.nodeName == 'BODY' || event.originalTarget.nodeName == 'HTML') {
$('.TEMPLATE-LevelMap').data('down', false);
}
} catch (e) {}
}
});