4 changed files with 70 additions and 1 deletions
@ -0,0 +1,28 @@
|
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
use PhpCsFixer\Config; |
||||
use PhpCsFixer\Finder; |
||||
|
||||
return (new Config()) |
||||
->setRiskyAllowed(false) |
||||
->setRules([ |
||||
'@auto' => true |
||||
]) |
||||
// 💡 by default, Fixer looks for `*.php` files excluding `./vendor/` - here, you can groom this config |
||||
->setFinder( |
||||
(new Finder()) |
||||
// 💡 root folder to check |
||||
->in(__DIR__) |
||||
// 💡 additional files, eg bin entry file |
||||
// ->append([__DIR__.'/bin-entry-file']) |
||||
// 💡 folders to exclude, if any |
||||
// ->exclude([/* ... */]) |
||||
// 💡 path patterns to exclude, if any |
||||
// ->notPath([/* ... */]) |
||||
// 💡 extra configs |
||||
// ->ignoreDotFiles(false) // true by default in v3, false in v4 or future mode |
||||
// ->ignoreVCS(true) // true by default |
||||
) |
||||
; |
||||
@ -0,0 +1,34 @@
|
||||
(function (Drupal) { |
||||
"use strict"; |
||||
|
||||
Drupal.behaviors.nouisliderYearFormat = { |
||||
// Weight needs to be higher than the module's behavior so we run after it.
|
||||
// Drupal behaviors don't have explicit weight in this API, but attaching
|
||||
// after DOM ready is fine since once() ensures the module ran first.
|
||||
attach: function (context, settings) { |
||||
const sliderEl = context.querySelector("#year.noUi-target"); |
||||
|
||||
if (!sliderEl || !sliderEl.noUiSlider) return; |
||||
if (sliderEl.dataset.yearFormatApplied) return; |
||||
sliderEl.dataset.yearFormatApplied = "true"; |
||||
|
||||
const inputFrom = document.getElementById("nouislider-input-from"); |
||||
const inputTo = document.getElementById("nouislider-input-to"); |
||||
|
||||
// The module's update listener gives inputs the raw float (e.g. 1971.00)
|
||||
// because no top-level format is set on the slider. We add our own
|
||||
// update listener that overwrites the input value with a rounded integer.
|
||||
// 'update' fires on drag but does NOT trigger navigation — only 'set' does.
|
||||
sliderEl.noUiSlider.on("update", function (values, handle) { |
||||
const rounded = Math.round(parseFloat(values[handle])); |
||||
if (handle === 0 && inputFrom) inputFrom.value = rounded; |
||||
if (handle === 1 && inputTo) inputTo.value = rounded; |
||||
}); |
||||
|
||||
// Fix the current displayed values in the inputs immediately
|
||||
const current = sliderEl.noUiSlider.get(); |
||||
if (inputFrom) inputFrom.value = Math.round(parseFloat(current[0])); |
||||
if (inputTo) inputTo.value = Math.round(parseFloat(current[1])); |
||||
}, |
||||
}; |
||||
})(Drupal); |
||||
Loading…
Reference in new issue