ibms-dome/Frontend/js/site.js

36 lines
1.0 KiB
JavaScript

$(function () {
$(".dropdown-menu.dropdown-select-menu").each((index, value) => {
setDropdownItem(value)
})
})
$.fn.droSetItem = function () {
setDropdownItem(this);
return this;
}
function setDropdownItem(menuEle) {
if ($(menuEle).find(".dropdown-item.active").length == 0) {
$(menuEle).find(".dropdown-item").first().addClass("active");
}
let actText = $(menuEle).find(".dropdown-item.active").first().text();
let actEleId = $(menuEle).prop("id");
$(`.dropdown-toggle[data-target=${actEleId}]`).text(actText);
$(menuEle).trigger("active:change", $(menuEle).find(".dropdown-item.active"));
}
onEvent("click", ".dropdown-menu.dropdown-select-menu .dropdown-item", function () {
$(this).parent(".dropdown-menu.dropdown-select-menu").find(".dropdown-item").removeClass("active");
$(this).addClass("active");
setDropdownItem($(this).parent(".dropdown-menu.dropdown-select-menu"));
})
function defDev(obj) {
let defSrc = 'img/defdev.png';
obj.src = defSrc;
}