/*
* Created by on 2018/1/19.
*/
var proList = "";
var isoformsArr = [];
var effects = "";
var oPOPWindow = $(".pop-isoform"),
oPOPWindowHeader = $(".pop-isoform-title-bar"),
oPOPScreening = $(".pop-isoform-screening"),
oPOPEmpty = $(".isoform-no-results");
oPOPNonempty = $(".isoform-results"),
oPOPTitle = $(".pop-isoform-title"),
oPOPTbl = $(".pop-isoform-data"),
oPOPTblHeader = $(".pop-isoform-tbl-header"),
oPOPTblContent = $(".pop-isoform-tbl-content"),
// 当前靶点名称
sTargetName = $("#category_tit").find("h1").text(),
// 已经选中的亚型数组
aSelectedItem = [];
// 当前靶点下所有靶点的数组
var aAllSelectedItem = (function(){
var aAllSelectedItem = [];
var oIsoformItems = $(".isoform-none-list > li");
for( var i = 0; i < oIsoformItems.length; i++ ){
aAllSelectedItem.push(oIsoformItems.eq(i).find("p > span").html());
}
return aAllSelectedItem;
})();
function fnTargetIsoformShow(){
var maxWidth = 125;
for(var i=0; i<$(".isoform-list > li").length; i++ ){
var oThisIsoform = $(".isoform-list > li").eq(i);
var iBaseWidth = 125;
//console.log(oThisIsoform.width());
if ( oThisIsoform.width() + 15 > iBaseWidth && oThisIsoform.width() <=iBaseWidth*2 ){
if (oThisIsoform.width() + 15 <= 166.6 ){
if (166.6 > maxWidth) {
maxWidth = 166.6;
}
} else {
if (iBaseWidth * 2 > maxWidth) {
maxWidth = iBaseWidth * 2;
}
}
} else if ( oThisIsoform.width() + 15 > iBaseWidth*2 && oThisIsoform.width() <= iBaseWidth*3 ){
if (iBaseWidth*3 > maxWidth) {
maxWidth = iBaseWidth*3;
}
}
}
if (maxWidth == 166.6) {
$(".isoform-list > li").css({"width": "calc(100% / 6)"});
} else {
$(".isoform-list > li").css({"width":maxWidth +"px"});
}
}
function fnPOPIsoformShow() {
$(oPOPWindow).show();
$(".mask").show();
}
function fnPOPIsoformTitle() {
oPOPWindowHeader.find("#pop-isoform-taregt-name").text(sTargetName);
}
function fnScreeningShow() {
var aPrSelectedItems = aSelectedItem;
var oPOPScreeningHtml = "";
for(var i=0; i"+""+sIsofromText +""+ oIStyle+"
";
}
oPOPScreening.html(oPOPScreeningHtml);
oPOPScreening.find("div").css({"width":oPOPScreening.width()/aAllSelectedItem.length+"px"});
fnScreeningItemHover();
oPOPScreening.find("div").click(function () {
// $(oPOPNonempty).show();
// $(oPOPEmpty).hide();
if($(this).attr("class")=="active") {
$(this).removeClass("active");
$(this).find("p > i").css({"color":"transparent"});
$(this).find("p > i").removeClass('icon-remove').addClass('icon-ok');
console.log()
aSelectedItem.splice(jQuery.inArray($(this).find("p > span").html(),aSelectedItem),1);
}else {
$(this).addClass("active");
$(this).find("p > i").css({"color": "#FFF"});
$(this).find("p > i").removeClass('icon-ok').addClass('icon-remove');
aSelectedItem.push($(this).find("p > span").html());
}
//var aMaySelected = aAllSelectedItem;
fnPOPIsoformTblData(aSelectedItem,isoformsArr);
});
}
function fnScreeningItemHover() {
oPOPScreening.find("div").hover(
function () {
$(this).attr("class") == "active"? ($(this).find("p > i").removeClass("icon-ok").addClass("icon-remove")):$(this).find("p > i").css({"color":"#8972ac"});
},
function () {
$(this).attr("class") == "active"?($(this).find("p > i").removeClass("icon-remove").addClass("icon-ok")):($(this).find("p > i").css({"color":"transparent"}))
}
);
}
function getSelectedValue(){
aSelectedItem = [];
$('.pop-isoform-screening div').each(function () {
if($(this).attr("class")=="active") {
aSelectedItem.push($(this).find("p > span").html());
} else {
aMaySelected.push($(this).find("p > span").html());
}
})
}
function fnPOPIsoformTblData(arraySelected, aMaySelected){
arraySelected = [];
$('.pop-isoform-screening div').each(function () {
if($(this).attr("class")=="active") {
arraySelected.push($(this).find("p > span").html());
}
})
var aSelectedSort = fnSelectedItemsSort(arraySelected,aAllSelectedItem);
$.ajax({
url: "mce_category!getIsoformsProducts.shtml",
data:"cataNameTarget=" + $("#cataNameTarget").val() + "&isoformName=" + aSelectedSort.toString(),
cache:false,
dataType:'json',
async: false,
success:function(data){
$.each(data, function(i, item) {
if(i.trim()=="checkMessage"){
meaasge = item;
}
if (meaasge == "success") {
if (i.trim() == "proList") {
proList = item;
}
if (i.trim() == "isoformsArr") {
isoformsArr = item.split(",");
aMaySelected = isoformsArr;
}
if (i.trim() == "effectsArr") {
effects = item;
}
} else {
proList = "";
isoformsArr.length = 0;
}
});
}
});
// alert(aAllSelectedItem.toString());
if (proList!="") {
$(".isoform-results").show();
$(".isoform-no-results").addClass("hide");
var aNonSelected = fnNonSelectedSort(aSelectedSort, aMaySelected);
var sPOPTitle = "";
if(aSelectedSort.length == 0) {
sPOPTitle = sTargetName + " " + getFormatStr(effects.split(","), "&");
} else {
sPOPTitle += getFormatStr(aSelectedSort, "and") + " Specific " + getFormatStr(effects.split(","), "&");
}
oPOPTitle.find("#isoform-name").html(sPOPTitle);
// 加载数据列表的表头
var oPOPTblHeaderHtml = "";
oPOPTblHeaderHtml += "";
oPOPTblHeaderHtml += "" + Cart.productName + " | ";
for(var i in aSelectedSort) {
oPOPTblHeaderHtml += "" + aSelectedSort[i] + " | ";
}
for(var i in aNonSelected) {
oPOPTblHeaderHtml += "" + aNonSelected[i] + " | ";
}
if(aSelectedSort.length == 1) {
oPOPTblHeaderHtml += "" +aSelectedSort[0] +" Selectivity" + " | ";
}
oPOPTblHeaderHtml += "Purity | ";
oPOPTblHeaderHtml += "
";
oPOPTblHeader.html(oPOPTblHeaderHtml);
var oPOPTblContentHtml = "";
var proArray = proList.split("|");
for(var i = 0; i < proArray.length; i++) {
oPOPTblContentHtml += "";
var pro = proArray[i].split(";");
oPOPTblContentHtml += "" + pro[0] + " | ";
for(var j = 0; j < aSelectedSort.length; j ++) {
var icNotes = pro[2].split("__");
var num = 0;
var icValueStr = "";
for (var a = 0; a < icNotes.length; a ++) {
var icValue = icNotes[a].split(",");
if (icValue[0] == aSelectedSort[j]){
num = 1;
var note = "";
if (icValue[4] != "null" && icValue[4] != "") {
note = " (" + icValue[4] + ")";
}
if (icValue[2] != "null" && icValue[2] != "") {
if (icValue[1] != "null" && icValue[1] !='') {
icValueStr = icValueStr + icValue[1] + ", " + icValue[2] + note + "
";
} else {
icValueStr = icValueStr + icValue[2] + note + "
";
}
} else {
if (icValue[1] != "null" && icValue[1] !='') {
icValueStr = icValueStr + icValue[1] + note + "
";
}
}
}
}
if (num == 0) {
oPOPTblContentHtml += " | ";
} else {
oPOPTblContentHtml += "" +"" + icValueStr.substring(0,icValueStr.length-5) + " "+" "+" | ";
}
}
for(var j = 0; j < aNonSelected.length; j ++) {
var num = 0;
var icValueStr = "";
var icNotes = pro[2].split("__");
for (var a = 0; a < icNotes.length; a ++) {
var icValue = icNotes[a].split(",");
if (icValue[0] == aNonSelected[j]){
num = 1;
var note = "";
if (icValue[4] != "null" && icValue[4] != "") {
note = " (" + icValue[4] + ")";
}
if (icValue[2] != "null" && icValue[2] != "") {
if (icValue[1] != "null" && icValue[1] !='') {
icValueStr = icValueStr + icValue[1] + ", " + icValue[2] + note + "
";
} else {
icValueStr = icValueStr + icValue[2] + note + "
";
}
} else {
if (icValue[1] != "null" && icValue[1] !='') {
icValueStr = icValueStr + icValue[1] + note + "
";
}
}
}
}
if (num == 0) {
oPOPTblContentHtml += " | ";
} else {
oPOPTblContentHtml += "" +""+ icValueStr.substring(0,icValueStr.length-5) + " "+ " "+" | ";
}
}
if(aSelectedSort.length == 1) {
for(var j = 0; j < aSelectedSort.length; j ++) {
var icNotes = pro[2].split("_");
for (var a = 0; a < icNotes.length; a ++) {
var icValue = icNotes[a].split(",");
if (icValue[0] == aSelectedSort[j]){
if (icValue[3] != "null" && icValue[3] != "") {
if (icValue[3] == 'Selective') {
oPOPTblContentHtml += "" + icValue[3] +" " + pro[4] + " | ";
} else {
oPOPTblContentHtml += "" + (icValue[3] !='default' ? icValue[3] +" " : "") + pro[4] + " | ";
}
} else {
oPOPTblContentHtml += "" + pro[4] + " | ";
}
break;
}
}
}
}
oPOPTblContentHtml += "" + pro[3] + " | ";
oPOPTblContentHtml += "
";
}
oPOPTblContent.html(oPOPTblContentHtml);
fnPOPIsoformSize();
fnPOPTdHover();
} else {
$(".isoform-results").hide();
$("#empty-isoform-name").html(getFormatStr(aSelectedSort, "and"));
$(".isoform-no-results").removeClass("hide");
}
}
function fnPOPIsoformClose() {
$(document).click(function(){ fnPOPIsoformHide() });
$(".pop-isoform,.isoform-more,.isoform-none-list > li").click(function(event){ event.stopPropagation(); });
$(window).click(function () { fnPOPIsoformHide() });
$(oPOPWindow).find(".close").click(function () { fnPOPIsoformHide() })
}
function fnPOPIsoformHide() {
oPOPWindow.hide();
$(".mask").hide();
aSelectedItem.length = 0;
isoformsArr.length = 0;
}
function fnInitPOPIsoform(aSelected, aMaySelected){
fnPOPIsoformShow();
fnPOPIsoformTitle();
fnPOPIsoformTblData(aSelected,aMaySelected);
fnScreeningShow();
}
$(function () {
fnTargetIsoformShow();
$(".isoform-none-list > li").bind("click",function () {
aSelectedItem = [$(this).find("span").html()];
fnInitPOPIsoform(aSelectedItem,isoformsArr);
});
$(window).resize(function () {
fnPOPIsoformSize();
});
// fnPOPIsoformClose();
if (aAllSelectedItem.length > 0) {
fnPOPIsoformTblData(aSelectedItem, isoformsArr);
fnScreeningShow();
}
// $('#target-isoform_tit').on('click', function () {
// fnPOPIsoformTblData(aSelectedItem, isoformsArr);
// fnScreeningShow();
// });
});
function fnPOPIsoformSize() {
isTableFixed();
var headTbl = $(".pop-isoform-tbl-header");
var colNum = headTbl.find("th").length;
var contentTblDiv = $(".pop-isoform-content");
var contentTrLen = contentTblDiv.find("tr").length;
var isoformContentTbl = $(".pop-isoform-tbl-content");
var iPOPContentH = oPOPWindow.outerHeight() - oPOPWindowHeader.outerHeight() - oPOPScreening.outerHeight();
var iPOPTblContentH = iPOPContentH - oPOPTitle.outerHeight() - oPOPTblHeader.outerHeight() - 25;
var iPOPTblContentTblH = isoformContentTbl.outerHeight();
var borbtmPurple = "1px solid #ebe4f6";
contentTblDiv.css({"height":iPOPTblContentH+"px"});
if(iPOPTblContentTblH < iPOPTblContentH) {
contentTblDiv.removeClass("borbtm-purple");
isoformContentTbl.addClass("borbtm-purple");
} else {
isoformContentTbl.removeClass("borbtm-purple");
contentTblDiv.addClass("borbtm-purple");
}
var headW = [];
for(var i = 0; i < colNum; i++){
headW.push(headTbl.find("th").eq(i).outerWidth());
}
for(var j = 0; j < contentTrLen; j++){
for(var k = 0; k < headW.length; k ++){
isoformContentTbl.find("tr").eq(j).find("td").eq(k).css({"width":headW[k]+"px"});
}
}
//console.log(headW[0] +'=?'+ isoformContentTbl.find('tr').eq(0).find('td').eq(0).outerWidth());
if(headW[0] < isoformContentTbl.find('tr').eq(0).find('td').eq(0).outerWidth()) {
$('.pop-isoform-tbl-content td.col-name a').css({'word-break':'break-all'});
} else {
$('.pop-isoform-tbl-content td.col-name').css({'word-break':'normal'});
}
// $(".pop-isoform-content").scrollTop(0);
// $(".pop-isoform-content").perfectScrollbar();
}
function isTableFixed() {
var tbl = $(".pop-isoform-tbl");
var tblColNum = tbl.find("tr>th").length;
var flag = 6;
if(tblColNum <= flag) {
$(".pop-isoform-tbl").css({"table-layout":"fixed"});
$(".col-selectivity, .col-purity").css({"text-align":"center"});
} else {
$(".pop-isoform-tbl").css({"table-layout":"auto"});
$(".col-selectivity, .col-purity").css({"text-align":"left"});
}
}
function fnPOPTdHover() {
$(".IC50-sign").on('mouseover',function (event) {
$(".IC50-pop").hide();
var ic50Val = $(this).find(".IC50-pop>.IC50-bubble-box").html().split(':').join('').replace(/\s/g, "");
if(ic50Val) {
var IC50POP =$(this).find(".IC50-pop");
IC50POP.show();
var thisw = $(this).outerWidth();
var IC50w = IC50POP.eq(0).outerWidth();
var IC50POPLeft = (thisw-IC50w)/2;
var IC50POPArrLeft = IC50w/2-7;
$(this).addClass("pointer");
IC50POP.css({"left":IC50POPLeft+"px"});
IC50POP.find(".IC50-bubble-arrow").css({"left":IC50POPArrLeft+"px"});
// IC50POP.find(".IC50-bubble-arrow").removeClass("IC50-bubble-arrowD").addClass("IC50-bubble-arrowUP");
}
console.log(event.target.className);
if(event.target.className == "IC50-bubble-box"){
$(".IC50-pop").hide();
}
}
);
$(".IC50-sign").on('mouseleave', function () {
$(".IC50-pop").hide();
});
}