Browse Source

trailing zeros

master
rdrew 4 days ago
parent
commit
eb1be4ffa1
  1. 28
      .php-cs-fixer.dist.php
  2. 34
      js/nouislider-year-format.js
  3. 8
      vre2024.libraries.yml
  4. 1
      vre2024.theme

28
.php-cs-fixer.dist.php

@ -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
)
;

34
js/nouislider-year-format.js

@ -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);

8
vre2024.libraries.yml

@ -53,7 +53,7 @@ fontawesome5:
version: 5.15.4 version: 5.15.4
css: css:
component: component:
css/fontawesome5.css: {weight: -10} css/fontawesome5.css: { weight: -10 }
# Bootstrap Icons # Bootstrap Icons
bootstrap-icons: bootstrap-icons:
@ -68,3 +68,9 @@ maintenance:
css: css:
theme: theme:
css/maintenance.css: {} css/maintenance.css: {}
nouislider-year-format:
js:
js/nouislider-year-format.js: {}
dependencies:
- core/drupal

1
vre2024.theme

@ -9,6 +9,7 @@ function vre2024_preprocess_page(array &$variables) {
$variables['site_slogan'] = $config->get('slogan'); $variables['site_slogan'] = $config->get('slogan');
$variables['base_path'] = base_path(); $variables['base_path'] = base_path();
$variables['scrolltotop_on'] = 1; $variables['scrolltotop_on'] = 1;
$variables['#attached']['library'][] = 'vre2024/nouislider-year-format';
} }
/** /**
* Add current page to breadcrumb. * Add current page to breadcrumb.

Loading…
Cancel
Save