You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
824 B
30 lines
824 B
(function (Drupal) { |
|
"use strict"; |
|
|
|
Drupal.behaviors.nouisliderYearFormat = { |
|
attach: function (context, settings) { |
|
const sliderEl = context.querySelector("#year.noUi-target"); |
|
|
|
if (!sliderEl || !sliderEl.noUiSlider) return; |
|
|
|
// Prevent re-running if we've already patched this slider |
|
if (sliderEl.dataset.yearFormatApplied) return; |
|
sliderEl.dataset.yearFormatApplied = "true"; |
|
|
|
const integerFormat = { |
|
to: function (value) { |
|
return String(Math.round(value)); |
|
}, |
|
from: function (value) { |
|
return Math.round(Number(value)); |
|
}, |
|
}; |
|
|
|
sliderEl.noUiSlider.updateOptions({ |
|
format: integerFormat, |
|
tooltips: [integerFormat, integerFormat], |
|
ariaFormat: integerFormat, |
|
}); |
|
}, |
|
}; |
|
})(Drupal);
|
|
|