This commit is contained in:
Victor
2022-12-23 19:18:33 +03:00
parent 005f732424
commit 521bf00615
14 changed files with 112 additions and 109 deletions

View File

@ -25,14 +25,14 @@
getFormatItem,
getSelectText,
customStylesFormat,
nativOptionMultiple,
nativOptionOrdinary,
nativeOptionMultiple,
nativeOptionOrdinary,
clearSelect,
} from './components/utils';
import {
createBreadcrumb,
createInputSearch,
createNativSelectOption,
createNativeSelectOption,
createNativeSelect,
} from './components/create-element';
import { ru, en } from './language/language';
@ -416,19 +416,19 @@
}
const ulList = document.createElement('ul');
const nativSelect = createNativeSelect();
const nativeSelect = createNativeSelect();
let intputSearch = '';
let inputSearch = '';
this.random = random;
if (searchMode) {
if (lenguage === 'ru') {
intputSearch = createInputSearch(random, ru.placeholder);
inputSearch = createInputSearch(random, ru.placeholder);
} else {
intputSearch = createInputSearch(random, en.placeholder);
inputSearch = createInputSearch(random, en.placeholder);
}
ulList.appendChild(intputSearch);
ulList.appendChild(inputSearch);
}
ulList.classList.add('list');
@ -441,10 +441,10 @@
this.#element.appendChild(ulList);
this.#items.forEach((dataItem) => {
this.#element.appendChild(nativSelect);
this.#element.appendChild(nativeSelect);
const liItem = document.createElement('li');
const nativOption = createNativSelectOption();
const nativeOption = createNativeSelectOption();
const strongItem = document.createElement('strong');
liItem.classList.add('list__item');
@ -460,17 +460,17 @@
checkBox.classList.add('displayHide');
}
nativSelect.setAttribute('multiple', 'multiple');
nativeSelect.setAttribute('multiple', 'multiple');
}
let textNode = '';
if (dataItem.title) {
nativOption.text = dataItem.title;
nativOption.value = dataItem.title;
nativeOption.text = dataItem.title;
nativeOption.value = dataItem.title;
textNode = document.createTextNode(dataItem.title);
nativSelect.appendChild(nativOption);
nativeSelect.appendChild(nativeOption);
liItem.appendChild(textNode);
ulList.appendChild(liItem);
} else {
@ -546,7 +546,7 @@
const response = await fetch(url);
const dataUrl = await response.json();
const nativSelect = createNativeSelect();
const nativeSelect = createNativeSelect();
dataUrl.forEach((dataItem, index) => {
const item = {
@ -556,7 +556,7 @@
};
const ulUrl = this.#element.querySelector('.list');
const nativOption = createNativSelectOption();
const nativeOption = createNativeSelectOption();
const liUrl = document.createElement('li');
const textUrl = document.createTextNode(item.title);
@ -568,23 +568,23 @@
}
checkBox.setAttribute('id', `chbox-${item.id}`);
nativSelect.setAttribute('multiple', 'multiple');
nativeSelect.setAttribute('multiple', 'multiple');
liUrl.appendChild(checkBox);
}
liUrl.classList.add('list__item');
nativOption.value = item.title;
nativOption.text = item.title;
nativeOption.value = item.title;
nativeOption.text = item.title;
nativSelect.appendChild(nativOption);
nativeSelect.appendChild(nativeOption);
liUrl.appendChild(textUrl);
ulUrl.appendChild(liUrl);
this.#items.push(item);
});
this.#element.appendChild(nativSelect);
this.#element.appendChild(nativeSelect);
this.#items.filter((item, index) => {
if (typeof item !== 'object') {
@ -643,7 +643,7 @@
const options = this.#element.querySelectorAll('.list__item');
const select = this.#element.querySelector('.selected');
const nativOption = this.#element.querySelectorAll('.nativSelect__nativOption');
const nativeOption = this.#element.querySelectorAll('.nativeSelect__nativeOption');
const ulMultipul = document.createElement('ul');
@ -686,7 +686,7 @@
}
if (checkIndex === -1) {
nativOptionMultiple(nativOption, item.title, true);
nativeOptionMultiple(nativeOption, item.title, true);
this.#indexes.push(index);
select.innerText = '';
@ -714,7 +714,7 @@
this.#indexes.splice(checkIndex, 1);
this.#selectedItems.splice(checkIndex, 1);
nativOptionMultiple(nativOption, item.title, false);
nativeOptionMultiple(nativeOption, item.title, false);
}
if (!this.#selectedItems.length) {
@ -731,7 +731,7 @@
select.innerText = item.title;
this.#selectedItems = item;
nativOptionOrdinary(nativOption, item.title);
nativeOptionOrdinary(nativeOption, item.title);
options.forEach((option) => {
option.classList.remove('active');