forked from gajus/wholly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.wholly.min.js
executable file
·1 lines (1 loc) · 1.58 KB
/
jquery.wholly.min.js
1
(function(e){"use strict";var t=false;e.fn.wholly=function(){var n,r,i,s;r=function(t){var r=0;t.find("tr").each(function(){var t=n(e(this));if(t>r){r=t}});return r};n=function(t){var n=0;t.find("td, th").each(function(){var t=parseInt(e(this).attr("colspan"),10)||1;n+=t});return n};i=function(e,t){var n=[],r,i;while(t--){r=e;i=[];while(r--){i.push(null)}n.push(i)}return n};s=function(n,r){var i=n.find("tr");e.each(r,function(n){var s=i.eq(n),o=s.children(),u=0;if(t){console.groupCollapsed("Table row.","y:",n,"rowChildren.length:",o.length)}e.each(r[n],function(e){var i=r[n][e],s,a,f,l,c;if(i){if(t){console.log("x:",u,"cell:",i[0])}}else{i=o.eq(u++);s=parseInt(i.attr("colspan"),10)||1;a=parseInt(i.attr("rowspan"),10)||1;if(t){if(s>1||a>1){console.group("x:",e,"colspan:",s,"rowspan:",a,"cell:",i[0])}else{console.log("x:",e,"colspan:",s,"rowspan:",a,"cell:",i[0])}}for(f=0;f<a;f++){for(l=0;l<s;l++){if(t){console.log("relative row:",f,"relative cell:",l,"absolute row:",n+f,"absolute cell:",e+l)}r[n+f][e+l]=i}}if(s>1||a>1){console.groupEnd()}}c=i.data("wholly.index");if(c===undefined){i.data("wholly.index",e)}});if(t){console.groupEnd()}})};return this.each(function(){var n=e(this),o=r(n),u=n.find("tr").length,a=i(o,u),f;if(t){console.log("tableWidth:",o,"tableHeight:",u)}s(n,a);n.on("mouseenter","td, th",function(){var t=parseInt(e(this).attr("colspan"),10)||1,n=e(this).data("wholly.index"),r,i;f=e(this);r=n;i=n+t;e.each(a,function(t,n){e.each(n.slice(r,i),function(e,t){f=f.add(t)})});f.trigger("wholly.mouseenter")});n.on("mouseleave","td, th",function(){f.trigger("wholly.mouseleave")})})}})(jQuery)