magix-components
Version:
1 lines • 1.25 kB
JavaScript
define("mx-table/isticky",["magix","$"],function(_,e,i){var t=_("magix"),n=_("$");i.exports=t.View.extend({init:function(){var _=this;_.__e_=50;var e=n("#inmain");e.length||(e=n(window),_.__e_=0);var i=function(){_.__ea(e)};_.on("destroy",function(){e.off("scroll",i)}),e.on("scroll",i),_.__eb=e},__ee:function(){var _=this,e=n("#"+_.id),i=e.find("thead"),t=e.find("tbody>tr").eq(0),o="ph_"+_.id,s=n("#"+o);t.find("td").length&&(s.length||(s=n("<caption />").insertBefore(i).attr("id",o)),i.css({position:"absolute",zIndex:1})),_.__ec=s,_.__h=e,_.__ed=i},__ei:function(){var _=this,e=n.now();if(!_.__ef||_.__ef+3e3<e){_.__ef=e;var i=_.__h,t=void 0,o=void 0;t=_.__e_?i.offset().top+_.__eb.scrollTop()-_.__e_:i.offset().top,o=i.height();var s=i.find("tfoot"),a=0;return s.length&&(a=s.height()),_.__eg={min:t,max:t+o-_.__eh-a}}return _.__eg},render:function(){var _=this;_.__ee(),_.__ej(),setTimeout(_.wrapAsync(function(){_.__ea(_.__eb)}),0)},__ej:function(){var _=this,e=_.__ed,i=_.__ec,t=e.height();t!=_.__eh&&(e.css({marginTop:-t}),i.css("height",t),_.__eh=t)},__ea:function(_){var e=this,i=_.scrollTop(),t=e.__ei();i>t.min&&i<t.max?e.__ed.css({top:i-t.min,marginTop:"auto"}):e.__ed.css({marginTop:-e.__eh,position:"absolute",top:"auto"})}})});