2023-03-03 14:54:11 +03:00
|
|
|
|
import CGSelect from "cg-select";
|
2023-04-04 20:57:05 +03:00
|
|
|
|
import "./style.scss";
|
|
|
|
|
import "./src/buttonControlCode";
|
2023-02-23 15:49:34 +03:00
|
|
|
|
|
|
|
|
|
// ------------------------------Обычный селект--------------------
|
|
|
|
|
const dropdown = new CGSelect({
|
2023-03-03 14:54:11 +03:00
|
|
|
|
selector: ".cg-dropdown_one",
|
|
|
|
|
placeholder: "Choose a car",
|
|
|
|
|
label: "EXAMPLE",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
items: [
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"BMW",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
{
|
2023-03-03 14:54:11 +03:00
|
|
|
|
id: "213sade",
|
|
|
|
|
title: "Opel",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
value: 1,
|
|
|
|
|
},
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"Mersedes",
|
|
|
|
|
"MAN",
|
|
|
|
|
"Ferari",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
],
|
|
|
|
|
styles: {
|
|
|
|
|
head: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "830px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
list: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "824px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// dropdown.on('clear', function (e) {
|
|
|
|
|
// console.log(`this state: ${e}`);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
const droptheme = new CGSelect({
|
2023-03-03 14:54:11 +03:00
|
|
|
|
selector: ".cg-dropdown_theme",
|
|
|
|
|
placeholder: "Choose a car",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
items: [
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"BMW",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
{
|
2023-03-03 14:54:11 +03:00
|
|
|
|
id: "213sade",
|
|
|
|
|
title: "Opel",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
value: 1,
|
|
|
|
|
},
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"Mersedes",
|
|
|
|
|
"MAN",
|
|
|
|
|
"Ferari",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
],
|
|
|
|
|
styles: {
|
|
|
|
|
head: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "830px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
list: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "824px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
},
|
2023-03-03 14:54:11 +03:00
|
|
|
|
theme: "dark",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
});
|
|
|
|
|
// ------------------------------NativeSelect-----------------------
|
|
|
|
|
const dropdownNativeSelect = new CGSelect({
|
2023-03-03 14:54:11 +03:00
|
|
|
|
selector: ".cg-dropdown_selectNative",
|
|
|
|
|
placeholder: "Choose a car",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
nativeSelectMode: true,
|
|
|
|
|
items: [
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"BMW",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
{
|
2023-03-03 14:54:11 +03:00
|
|
|
|
id: "213sade",
|
|
|
|
|
title: "Opel",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
value: 1,
|
|
|
|
|
},
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"Mersedes",
|
|
|
|
|
"MAN",
|
|
|
|
|
"Ferari",
|
|
|
|
|
"Kamaz",
|
|
|
|
|
"Ural",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
],
|
|
|
|
|
styles: {
|
|
|
|
|
head: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "830px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
list: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "824px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
},
|
2023-03-03 14:54:11 +03:00
|
|
|
|
theme: "dark",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ------------------------------listDisplayMode--------------------
|
|
|
|
|
const dropdownlistDisplayMode = new CGSelect({
|
2023-03-03 14:54:11 +03:00
|
|
|
|
selector: ".cg-dropdown_listDisplayMode",
|
|
|
|
|
placeholder: "Choose a car",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
listDisplayMode: true,
|
|
|
|
|
items: [
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"BMW",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
{
|
2023-03-03 14:54:11 +03:00
|
|
|
|
id: "213sade",
|
|
|
|
|
title: "Opel",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
value: 1,
|
|
|
|
|
},
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"Mersedes",
|
|
|
|
|
"MAN",
|
|
|
|
|
"Ferari",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
],
|
|
|
|
|
styles: {
|
|
|
|
|
head: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "830px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
list: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "824px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// --------------------------------Категории--------------------------
|
|
|
|
|
const dropdown4 = new CGSelect({
|
2023-03-03 14:54:11 +03:00
|
|
|
|
selector: ".cg-dropdown_categories",
|
|
|
|
|
placeholder: "Choose region",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
searchMode: true,
|
|
|
|
|
items: [
|
|
|
|
|
{
|
2023-03-03 14:54:11 +03:00
|
|
|
|
category: "Russia",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
categoryItems: [
|
|
|
|
|
{
|
2023-03-03 14:54:11 +03:00
|
|
|
|
id: "28qwds",
|
|
|
|
|
title: "Москва",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
value: 0,
|
|
|
|
|
},
|
|
|
|
|
,
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"Ростов-на-дону",
|
|
|
|
|
"Саратов",
|
|
|
|
|
"Волгоград",
|
|
|
|
|
"Донецк",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
2023-03-03 14:54:11 +03:00
|
|
|
|
category: "USA",
|
|
|
|
|
categoryItems: ["Alabama", "Texas", "Colorado", "Klirens", "Los-Angeles"],
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
{
|
2023-03-03 14:54:11 +03:00
|
|
|
|
category: "France",
|
|
|
|
|
categoryItems: ["Paris"],
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
styles: {
|
|
|
|
|
head: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "830px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
list: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "824px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
placeholder: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
maxWidth: "500px ",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
multiselect: true,
|
|
|
|
|
multiselectTag: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//----------------управление с помощью кнопок----------------------------------
|
|
|
|
|
const dropdownBtn = new CGSelect({
|
2023-03-03 14:54:11 +03:00
|
|
|
|
selector: ".cg-dropdown_usedBtn",
|
|
|
|
|
placeholder: "Choose a car",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
searchMode: true,
|
|
|
|
|
items: [
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"BMW",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
{
|
2023-03-03 14:54:11 +03:00
|
|
|
|
id: "213sade",
|
|
|
|
|
title: "Opel",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
value: 1,
|
|
|
|
|
},
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"Mersedes",
|
|
|
|
|
"MAN",
|
|
|
|
|
"max",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
],
|
|
|
|
|
styles: {
|
|
|
|
|
head: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "830px",
|
|
|
|
|
color: "black",
|
|
|
|
|
backgroundColor: "rgb(176 223 167)",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
list: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "824px",
|
|
|
|
|
color: "black",
|
|
|
|
|
backgroundColor: "rgb(176 223 167)",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
caret: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
borderTop: "6px solid black",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
search: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
backgroundColor: "#d7ffff",
|
|
|
|
|
borderRadius: "5px",
|
|
|
|
|
borderBottom: "none",
|
|
|
|
|
width: "95%",
|
|
|
|
|
color: "black",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
multiselect: true,
|
|
|
|
|
});
|
|
|
|
|
|
2023-03-03 14:54:11 +03:00
|
|
|
|
const buttonOpen = document.querySelector(".button__open");
|
|
|
|
|
const buttonClose = document.querySelector(".button__close");
|
2023-02-23 15:49:34 +03:00
|
|
|
|
|
2023-03-03 14:54:11 +03:00
|
|
|
|
dropdownBtn.buttonControl(buttonOpen, "open");
|
|
|
|
|
dropdownBtn.buttonControl(buttonClose, "close");
|
2023-02-23 15:49:34 +03:00
|
|
|
|
|
|
|
|
|
//-------------------------Функция Disabled----------------------------------
|
|
|
|
|
const dropdownDisabled = new CGSelect({
|
2023-03-03 14:54:11 +03:00
|
|
|
|
selector: ".cg-dropdown_checkboxDisable",
|
|
|
|
|
placeholder: "Choose a car",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
searchMode: true,
|
|
|
|
|
items: [
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"BMW",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
{
|
2023-03-03 14:54:11 +03:00
|
|
|
|
id: "213sade",
|
|
|
|
|
title: "Opel",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
value: 1,
|
|
|
|
|
},
|
2023-03-03 14:54:11 +03:00
|
|
|
|
"Mersedes",
|
|
|
|
|
"MAN",
|
|
|
|
|
"max",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
],
|
|
|
|
|
styles: {
|
|
|
|
|
head: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "830px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
list: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "824px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
placeholder: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
maxWidth: "500px ",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
multiselect: true,
|
|
|
|
|
});
|
|
|
|
|
dropdownDisabled.disabled(true);
|
2023-03-03 14:54:11 +03:00
|
|
|
|
let chbox = document.getElementById("checkboxDisable");
|
2023-02-23 15:49:34 +03:00
|
|
|
|
|
2023-03-03 14:54:11 +03:00
|
|
|
|
chbox.addEventListener("click", () => {
|
2023-02-23 15:49:34 +03:00
|
|
|
|
if (chbox.checked == true) {
|
|
|
|
|
dropdownDisabled.disabled(false);
|
|
|
|
|
} else {
|
|
|
|
|
dropdownDisabled.disabled(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ------------------------------URL--------------------
|
|
|
|
|
const dropdown3 = new CGSelect({
|
2023-03-03 14:54:11 +03:00
|
|
|
|
selector: ".cg-dropdown_three",
|
|
|
|
|
placeholder: "URL",
|
|
|
|
|
url: "https://jsonplaceholder.typicode.com/todos",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
searchMode: true,
|
|
|
|
|
darkTheme: false,
|
2023-03-03 14:54:11 +03:00
|
|
|
|
language: "ru",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
styles: {
|
|
|
|
|
head: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "830px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
list: {
|
2023-03-03 14:54:11 +03:00
|
|
|
|
width: "824px",
|
2023-02-23 15:49:34 +03:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
multiselect: true,
|
|
|
|
|
});
|
2023-03-03 14:54:11 +03:00
|
|
|
|
|
|
|
|
|
const dropCall = new CGSelect({
|
|
|
|
|
selector: ".cg-dropdown_callback",
|
|
|
|
|
placeholder: "Choose a car",
|
|
|
|
|
items: [
|
|
|
|
|
"BMW",
|
|
|
|
|
{
|
|
|
|
|
id: "213sade",
|
|
|
|
|
title: "Opel",
|
|
|
|
|
value: 1,
|
|
|
|
|
},
|
|
|
|
|
"Mersedes",
|
|
|
|
|
"MAN",
|
|
|
|
|
"Ferari",
|
|
|
|
|
],
|
|
|
|
|
styles: {
|
|
|
|
|
head: {
|
|
|
|
|
width: "830px",
|
|
|
|
|
},
|
|
|
|
|
list: {
|
|
|
|
|
width: "824px",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
dropCall.on("select", (state, value) => {
|
|
|
|
|
console.log(value);
|
|
|
|
|
});
|