Created
July 15, 2016 12:30
-
-
Save rickydazla/a135c7620f5e55ffbc5c1df49f6f0eb9 to your computer and use it in GitHub Desktop.
Tables highlighting jazz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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