44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import Choices from "choices.js";
|
|
|
|
const selects = document.querySelectorAll('select[multiple]');
|
|
if(selects) {
|
|
Array.prototype.forEach.call(selects, (select: HTMLInputElement) => {
|
|
const choices = new Choices(select);
|
|
});
|
|
}
|
|
|
|
|
|
/*document.addEventListener('DOMContentLoaded', function() {
|
|
setDistance('.set-distance-js');
|
|
});
|
|
|
|
function setDistance(selector: string) {
|
|
const fields = document.querySelectorAll(selector);
|
|
if(fields) {
|
|
Array.prototype.forEach.call(fields, (field: HTMLInputElement) => {
|
|
if(field.dataset.relation){
|
|
const relatedField = <HTMLInputElement>document.getElementById(field.dataset.relation);
|
|
|
|
if(relatedField) {
|
|
field.addEventListener('input', (e) => {
|
|
e.preventDefault();
|
|
|
|
const dataList = <HTMLDataListElement>document.getElementById('destinations');
|
|
if(dataList) {
|
|
var option = Array.prototype.find.call(dataList.options, function(option) {
|
|
return option.value === field.value;
|
|
});
|
|
|
|
// Get distance
|
|
const distance = option.getAttribute('distance');
|
|
if(distance) relatedField.value = distance;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
*/
|
|
export {}
|