MediaWiki:Common.js: Difference between revisions
MediaWiki interface page
More actions
No edit summary Tags: Mobile edit Mobile web edit |
No edit summary Tags: Mobile edit Mobile web edit |
||
| Line 17: | Line 17: | ||
// Versioned init guard (allows safe updates without stale blocks) | // Versioned init guard (allows safe updates without stale blocks) | ||
var LEVELS_VERSION = | var LEVELS_VERSION = 4; // bumped: mouse-only slider + tick/label polish | ||
if (typeof COMMON.levelsInit === "number" && COMMON.levelsInit >= LEVELS_VERSION) return; | if (typeof COMMON.levelsInit === "number" && COMMON.levelsInit >= LEVELS_VERSION) return; | ||
COMMON.levelsInit = LEVELS_VERSION; | COMMON.levelsInit = LEVELS_VERSION; | ||
| Line 575: | Line 576: | ||
document.addEventListener("pointercancel", endDrag, true); | document.addEventListener("pointercancel", endDrag, true); | ||
// | // Mouse-only slider interaction: | ||
// - Remove keyboard-driven adjustments on custom sliders | |||
// - Block native <input type="range"> from changing via keyboard (if present) | |||
var _SV_BLOCK_KEYS = { | |||
ArrowLeft: 1, ArrowRight: 1, ArrowUp: 1, ArrowDown: 1, | |||
Left: 1, Right: 1, Up: 1, Down: 1, | |||
Home: 1, End: 1, PageUp: 1, PageDown: 1 | |||
}; | |||
document.addEventListener( | document.addEventListener( | ||
"keydown", | "keydown", | ||
function (e) { | function (e) { | ||
var key = e && e.key; | |||
if (!_SV_BLOCK_KEYS[key]) return; | |||
var el = document.activeElement; | var el = document.activeElement; | ||
if (!el | if (!el) return; | ||
// Native range inputs (keep mouse drag, disable keyboard nudges) | |||
if (isRangeInput(el) && el.classList && el.classList.contains("sv-level-range")) { | |||
e.preventDefault(); | |||
return; | |||
} | |||
// Custom sliders (we keep focus behaviors, but no keyboard changes) | |||
var slider = closest(el, ".sv-level-range--custom, .sv-level-range[data-sv-slider='1']"); | |||
if (slider) { | |||
e.preventDefault(); | |||
var | |||
return; | return; | ||
} | } | ||
}, | }, | ||
true | true | ||