Skip to content

Instantly share code, notes, and snippets.

@rickydazla
Created July 15, 2016 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickydazla/a135c7620f5e55ffbc5c1df49f6f0eb9 to your computer and use it in GitHub Desktop.
Save rickydazla/a135c7620f5e55ffbc5c1df49f6f0eb9 to your computer and use it in GitHub Desktop.
Tables highlighting jazz
var SizeTableApp = (function(HighLightLogik, $){
HighLightLogik = {
init:function(){HighLightLogik.prepareActiveSizeTable();},
prepareActiveSizeTable: function() {
$(document).ready(function() {
var tableWrap = $("#table-wrapper");
var u;
var t = 1;
tableWrap.find("table").find("td").mouseover(function() {
var x = $(this).parent();
var y = x.parent();
var w = x.find("td").index(this);
var z = x.parent().find("tr").index(x);
if (u) {
$(u.cell).removeClass("selectedCell");
if (u.nTr != z) {
$(y.children()[u.nTr]).find("th, td").removeClass("highlightHor")
}
if (u.nTd != w) {
y.find("tr td:nth-child(" + (u.nTd + 1) + "), tr th:nth-child(" + (u.nTd + 1) + ")").removeClass("highlightVer")
}
}
if (w > -1) {
$(this).addClass("selectedCell");
y.find("tr td:nth-child(" + (w + 1) + "), tr th:nth-child(" + (w + 1) + ")").addClass("highlightVer");
$(y.children()[z]).find("td").addClass("highlightHor")
}
u = {
cell: this,
nTr: z,
nTd: w
}
$("table").addClass("hoverated");
});
tableWrap.find("table").mouseout(function() {
$(this).find("th, td").removeClass("highlightHor").removeClass("highlightVer").removeClass("selectedCell");
$("table").removeClass("hoverated");
})
})
}
};
return HighLightLogik;
})(SizeTableApp || {}, $).init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment