var $effectTable = $('#cell-table');
function trHeadFixed() {
var $cellInfo = $(".cell-table");
var cellInfoH = $cellInfo.outerHeight();
if(cellInfoH > 380) {
$(".cell-table .tr-head").addClass("tr-fixed");
}else {
$(".cell-table .tr-head").removeClass("tr-fixed");
}
}
$(function () {
trHeadFixed();
})
var cells = [];
var cellularEffectsListH = 0;
function initCellSelectValue() {
$effectTable.find('[data-cell-value]').each(function (index, trDom) {
var arr = $(this).attr("data-cell-value").split(';');
arr.map(item => {
if ($.inArray(item.trim(), cells) == -1) {
cells.push(item.trim());
}
})
});
if (cells.length > 0) {
var html = '
'+
''+
// ''+
'
' + '' ;
cells.map((item, index) => {
html += '
' +
'' +
'' +
'';
});
html += '' + '' + '' +
'' + '
';
$effectTable.parent(".cellular-effects-list").prev('[data-cell-title]').html(html);
$('.ic_cell-search').on('click', function (e) {
searchCell();
});
} else {
$effectTable.parent(".cellular-effects-list").prev('[data-cell-title]').hide()
}
$('.cell-table-filter-ic').on('click',function(e){
e.stopPropagation();
if ($('.table-filter-list').is(":hidden")) {
$(".table-filter-list").hide();
$('.table-filter-list').show();
} else {
$('.table-filter-list').hide();
}
});
$(".btn-cell-confirm").click(function () {
var $ul = $(this).parent().parent();
$ul.hide();
var arr = [];
$("input[type='checkbox']:checked").each(function(){
arr.push($(this).val().trim());
});
if (arr.length === 0) {
// $effectTable.find('.row-table').parent().parent().show();
$effectTable.find('tr').show();
} else {
$effectTable.find('[data-cell-value]').each(function (index, trDom) {
var display = 0;
arr.map(item => {
if (('; ' + $(this).attr("data-cell-value") + '; ').includes('; ' + item + '; ')) {
display = 1;
}
});
if (display) {
$(this).show();
} else {
$(this).hide();
}
});
}
isOverflow();
trHeadFixed();
hoverPoptip(".effect-temp-name");
hoverPoptip(".effect-temp-desc");
});
$('.btn-cell-cancle').click(function () {
clearCheckboxes();
$('#cellSearchInput').val('');
$('.table-filter-list').find("li").show();
$effectTable.find('tr').show();
$(".cellular-effects-list").css("overflow-y","auto");
trHeadFixed();
isOverflow();
hoverPoptip(".effect-temp-name");
hoverPoptip(".effect-temp-desc");
});
$('#cellSearchInput').keydown(function (event) {
if (event.keyCode === 13) {
searchCell();
}
});
}
// line-clamp-2
$.each($(".effect-temp-desc"), function (){
var poptipContH = $(this).find(".poptip-cont").outerHeight();
if(poptipContH > 40) {
$(this).find(".poptip-cont").addClass("line-clamp-2");
}else {
$(this).on("mouseenter",function (){
$(this).find(".poptip-box").hide();
})
}
})
function isOverflow() {
cellularEffectsListH = $(".cell-table").outerHeight();
if(cellularEffectsListH < 380) {
$(".cellular-effects-list").css("overflow-y", "visible");
}else {
$(".cellular-effects-list").css("overflow-y","auto");
}
}
function searchCell() {
var searchValue = $('#cellSearchInput').val();
if (searchValue !== '') {
$('.table-filter-list').find("li").each(function (index, item) {
if ($(this).text().toLowerCase().includes(searchValue.toLowerCase())) {
$(this).show();
} else {
$(this).hide();
}
});
} else {
$('.table-filter-list').find("li").show();
}
}
function clearCheckboxes() {
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
// 遍历并取消选择
checkboxes.forEach(function(checkbox) {
checkbox.checked = false;
});
}
function CellMore() {
var ParmacokineticsScroll = 0;
$("#J-cpd-pharmacokinetics-viewhide").find(".view_more").click(function () {
var ParmacokineticsScroll = $(window).scrollTop();
$("#parmacokinetics-table > tbody").removeClass("first-two");
viewMore("#J-cpd-pharmacokinetics-viewhide");
$("body,html").animate({scrollTop: ParmacokineticsScroll + "px"}, 50);
});
$("#J-cpd-pharmacokinetics-viewhide").find(".collapse").click(function () {
var ParmacokineticsScroll = $(window).scrollTop();
$("#parmacokinetics-table > tbody").addClass("first-two");
$("body,html").animate({scrollTop: ParmacokineticsScroll + "px"}, 500);
collapse("#J-cpd-pharmacokinetics-viewhide");
});
}
function CellMore2() {
$("#J-cpd-solution-product-viewhide").find(".view_more").click(function () {
var ParmacokineticsScroll = $(window).scrollTop();
$("#solution-product-table > tbody").removeClass("first-five");
viewMore("#J-cpd-solution-product-viewhide");
$("body,html").animate({scrollTop: ParmacokineticsScroll + "px"}, 50);
});
$("#J-cpd-solution-product-viewhide").find(".collapse").click(function () {
var ParmacokineticsScroll = $(window).scrollTop();
$("#solution-product-table > tbody").addClass("first-five");
$("body,html").animate({scrollTop: ParmacokineticsScroll + "px"}, 500);
collapse("#J-cpd-solution-product-viewhide");
});
}
document.addEventListener('click', function(event) {
var cellBox = document.querySelector('.table-filter-list');
if (cellBox && !cellBox.contains(event.target)) {
cellBox.style.display = 'none';
}
});
function hoverPoptip(ele) {
var ahrTableH = Math.floor($(".cellular-effects-list ").outerHeight());
var boxScrollTop = 0;
$(".cellular-effects-list").scroll(function(){
boxScrollTop = $(this).scrollTop();
})
$(ele).on("mouseenter", function(){
var currentHoverBoxH = $(this).outerHeight();
var currentPoptipH = $(this).find(".poptip-box").outerHeight();
var position = $(this).position();
if(Math.floor(position.top) + currentPoptipH + currentHoverBoxH >= ahrTableH) {
$(this).addClass("over-border");
}else {
$(this).removeClass("over-border");
}
})
}
hoverPoptip(".effect-temp-name");
hoverPoptip(".effect-temp-desc");
$('.poptip').on("mouseleave", function(){
$(this).removeClass("over-border");
})
isOverflow();
CellMore();
CellMore2();
initCellSelectValue();