All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.bower_components.datatables.net-fixedheader.js.dataTables.fixedHeader.min.js Maven / Gradle / Ivy

The newest version!
/*! FixedHeader 3.1.5
 * ©2009-2018 SpryMedia Ltd - datatables.net/license
 */
(function(a){if(typeof define==="function"&&define.amd){define(["jquery","datatables.net"],function(b){return a(b,window,document)})}else{if(typeof exports==="object"){module.exports=function(b,c){if(!b){b=window}if(!c||!c.fn.dataTable){c=require("datatables.net")(b,c).$}return a(c,b,b.document)}}else{a(jQuery,window,document)}}}(function(f,d,a,g){var e=f.fn.dataTable;var b=0;var c=function(i,h){if(!(this instanceof c)){throw"FixedHeader must be initialised with the 'new' keyword."}if(h===true){h={}}i=new e.Api(i);this.c=f.extend(true,{},c.defaults,h);this.s={dt:i,position:{theadTop:0,tbodyTop:0,tfootTop:0,tfootBottom:0,width:0,left:0,tfootHeight:0,theadHeight:0,windowHeight:f(d).height(),visible:true},headerMode:null,footerMode:null,autoWidth:i.settings()[0].oFeatures.bAutoWidth,namespace:".dtfc"+(b++),scrollLeft:{header:-1,footer:-1},enable:true};this.dom={floatingHeader:null,thead:f(i.table().header()),tbody:f(i.table().body()),tfoot:f(i.table().footer()),header:{host:null,floating:null,placeholder:null},footer:{host:null,floating:null,placeholder:null}};this.dom.header.host=this.dom.thead.parent();this.dom.footer.host=this.dom.tfoot.parent();var j=i.settings()[0];if(j._fixedHeader){throw"FixedHeader already initialised on table "+j.nTable.id}j._fixedHeader=this;this._constructor()};f.extend(c.prototype,{enable:function(h){this.s.enable=h;if(this.c.header){this._modeChange("in-place","header",true)}if(this.c.footer&&this.dom.tfoot.length){this._modeChange("in-place","footer",true)}this.update()},headerOffset:function(h){if(h!==g){this.c.headerOffset=h;this.update()}return this.c.headerOffset},footerOffset:function(h){if(h!==g){this.c.footerOffset=h;this.update()}return this.c.footerOffset},update:function(){this._positions();this._scroll(true)},_constructor:function(){var k=this;var j=this.s.dt;f(d).on("scroll"+this.s.namespace,function(){k._scroll()}).on("resize"+this.s.namespace,e.util.throttle(function(){k.s.position.windowHeight=f(d).height();k.update()},50));var i=f(".fh-fixedHeader");if(!this.c.headerOffset&&i.length){this.c.headerOffset=i.outerHeight()}var h=f(".fh-fixedFooter");if(!this.c.footerOffset&&h.length){this.c.footerOffset=h.outerHeight()}j.on("column-reorder.dt.dtfc column-visibility.dt.dtfc draw.dt.dtfc column-sizing.dt.dtfc responsive-display.dt.dtfc",function(){k.update()});j.on("destroy.dtfc",function(){if(k.c.header){k._modeChange("in-place","header",true)}if(k.c.footer&&k.dom.tfoot.length){k._modeChange("in-place","footer",true)}j.off(".dtfc");f(d).off(k.s.namespace)});this._positions();this._scroll()},_clone:function(k,l){var j=this.s.dt;var i=this.dom[k];var h=k==="header"?this.dom.thead:this.dom.tfoot;if(!l&&i.floating){i.floating.removeClass("fixedHeader-floating fixedHeader-locked")}else{if(i.floating){i.placeholder.remove();this._unsize(k);i.floating.children().detach();i.floating.remove()}i.floating=f(j.table().node().cloneNode(false)).css("table-layout","fixed").attr("aria-hidden","true").removeAttr("id").append(h).appendTo("body");i.placeholder=h.clone(false);i.placeholder.find("*[id]").removeAttr("id");i.host.prepend(i.placeholder);this._matchWidths(i.placeholder,i.floating)}},_matchWidths:function(m,l){var j=function(n){return f(n,m).map(function(){return f(this).width()}).toArray()};var k=function(o,n){f(o,l).each(function(p){f(this).css({width:n[p],minWidth:n[p]})})};var i=j("th");var h=j("td");k("th",i);k("td",h)},_unsize:function(i){var h=this.dom[i].floating;if(h&&(i==="footer"||(i==="header"&&!this.s.autoWidth))){f("th, td",h).css({width:"",minWidth:""})}else{if(h&&i==="header"){f("th, td",h).css("min-width","")}}},_horizontal:function(k,l){var j=this.dom[k];var h=this.s.position;var i=this.s.scrollLeft;if(j.floating&&i[k]!==l){j.floating.css("left",h.left-l);i[k]=l}},_modeChange:function(o,n,k){var m=this.s.dt;var l=this.dom[n];var h=this.s.position;var j=this.dom[n==="footer"?"tfoot":"thead"];var i=f.contains(j[0],a.activeElement)?a.activeElement:null;if(i){i.blur()}if(o==="in-place"){if(l.placeholder){l.placeholder.remove();l.placeholder=null}this._unsize(n);if(n==="header"){l.host.prepend(j)}else{l.host.append(j)}if(l.floating){l.floating.remove();l.floating=null}}else{if(o==="in"){this._clone(n,k);l.floating.addClass("fixedHeader-floating").css(n==="header"?"top":"bottom",this.c[n+"Offset"]).css("left",h.left+"px").css("width",h.width+"px");if(n==="footer"){l.floating.css("top","")}}else{if(o==="below"){this._clone(n,k);l.floating.addClass("fixedHeader-locked").css("top",h.tfootTop-h.theadHeight).css("left",h.left+"px").css("width",h.width+"px")}else{if(o==="above"){this._clone(n,k);l.floating.addClass("fixedHeader-locked").css("top",h.tbodyTop).css("left",h.left+"px").css("width",h.width+"px")}}}}if(i&&i!==a.activeElement){setTimeout(function(){i.focus()},10)}this.s.scrollLeft.header=-1;this.s.scrollLeft.footer=-1;this.s[n+"Mode"]=o},_positions:function(){var l=this.s.dt;var k=l.table();var h=this.s.position;var o=this.dom;var j=f(k.node());var n=j.children("thead");var m=j.children("tfoot");var i=o.tbody;h.visible=j.is(":visible");h.width=j.outerWidth();h.left=j.offset().left;h.theadTop=n.offset().top;h.tbodyTop=i.offset().top;h.theadHeight=h.tbodyTop-h.theadTop;if(m.length){h.tfootTop=m.offset().top;h.tfootBottom=h.tfootTop+m.outerHeight();h.tfootHeight=h.tfootBottom-h.tfootTop}else{h.tfootTop=h.tbodyTop+i.outerHeight();h.tfootBottom=h.tfootTop;h.tfootHeight=h.tfootTop}},_scroll:function(i){var m=f(a).scrollTop();var l=f(a).scrollLeft();var h=this.s.position;var k,j;if(!this.s.enable){return}if(this.c.header){if(!h.visible||m<=h.theadTop-this.c.headerOffset){k="in-place"}else{if(m<=h.tfootTop-h.theadHeight-this.c.headerOffset){k="in"}else{k="below"}}if(i||k!==this.s.headerMode){this._modeChange(k,"header",i)}this._horizontal("header",l)}if(this.c.footer&&this.dom.tfoot.length){if(!h.visible||m+h.windowHeight>=h.tfootBottom+this.c.footerOffset){j="in-place"}else{if(h.windowHeight+m>h.tbodyTop+h.tfootHeight+this.c.footerOffset){j="in"}else{j="above"}}if(i||j!==this.s.footerMode){this._modeChange(j,"footer",i)}this._horizontal("footer",l)}}});c.version="3.1.5";c.defaults={header:true,footer:false,headerOffset:0,footerOffset:0};f.fn.dataTable.FixedHeader=c;f.fn.DataTable.FixedHeader=c;f(a).on("init.dt.dtfh",function(l,i,h){if(l.namespace!=="dt"){return}var m=i.oInit.fixedHeader;var k=e.defaults.fixedHeader;if((m||k)&&!i._fixedHeader){var j=f.extend({},k,m);if(m!==false){new c(i,j)}}});e.Api.register("fixedHeader()",function(){});e.Api.register("fixedHeader.adjust()",function(){return this.iterator("table",function(i){var h=i._fixedHeader;if(h){h.update()}})});e.Api.register("fixedHeader.enable()",function(h){return this.iterator("table",function(j){var i=j._fixedHeader;h=(h!==g?h:true);if(i&&h!==i.s.enable){i.enable(h)}})});e.Api.register("fixedHeader.disable()",function(){return this.iterator("table",function(i){var h=i._fixedHeader;if(h&&h.s.enable){h.enable(false)}})});f.each(["header","footer"],function(h,j){e.Api.register("fixedHeader."+j+"Offset()",function(k){var i=this.context;if(k===g){return i.length&&i[0]._fixedHeader?i[0]._fixedHeader[j+"Offset"]():g}return this.iterator("table",function(m){var l=m._fixedHeader;if(l){l[j+"Offset"](k)}})})});return c}));




© 2015 - 2025 Weber Informatics LLC | Privacy Policy