forked from Wavyzz/dolibarr
Last version of JQuery 1.12 and DataTables Componenent with working
export Excel,CVS,PDF, etc..
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,22 +1,23 @@
|
||||
/*!
|
||||
AutoFill 1.2.1
|
||||
©2008-2014 SpryMedia Ltd - datatables.net/license
|
||||
AutoFill 2.1.1
|
||||
©2008-2015 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
(function(o,j,m){var l=function(c,k){var h=function(d,b){if(!(this instanceof h))throw"Warning: AutoFill must be initialised with the keyword 'new'";if(!c.fn.dataTableExt.fnVersionCheck("1.7.0"))throw"Warning: AutoFill requires DataTables 1.7 or greater";this.c={};this.s={filler:{height:0,width:0},border:{width:2},drag:{startX:-1,startY:-1,startTd:null,endTd:null,dragging:!1},screen:{interval:null,y:0,height:0,scrollTop:0},scroller:{top:0,bottom:0},columns:[]};this.dom={table:null,filler:null,borderTop:null,
|
||||
borderRight:null,borderBottom:null,borderLeft:null,currentTarget:null};this.fnSettings=function(){return this.s};this._fnInit(d,b);return this};h.prototype={_fnInit:function(d,b){var a=this;this.s.dt=k.Api?(new k.Api(d)).settings()[0]:d.fnSettings();this.s.init=b||{};this.dom.table=this.s.dt.nTable;c.extend(!0,this.c,h.defaults,b);this._initColumns();var e=c("<div/>",{"class":"AutoFill_filler"}).appendTo("body");this.dom.filler=e[0];this.s.filler.height=e.height();this.s.filler.width=e.width();e[0].style.display=
|
||||
"none";var g,f=j.body;""!==a.s.dt.oScroll.sY&&(a.s.dt.nTable.parentNode.style.position="relative",f=a.s.dt.nTable.parentNode);g=c("<div/>",{"class":"AutoFill_border"});this.dom.borderTop=g.clone().appendTo(f)[0];this.dom.borderRight=g.clone().appendTo(f)[0];this.dom.borderBottom=g.clone().appendTo(f)[0];this.dom.borderLeft=g.clone().appendTo(f)[0];e.on("mousedown.DTAF",function(b){this.onselectstart=function(){return false};a._fnFillerDragStart.call(a,b);return false});c("tbody",this.dom.table).on("mouseover.DTAF mouseout.DTAF",
|
||||
">tr>td, >tr>th",function(b){a._fnFillerDisplay.call(a,b)});c(this.dom.table).on("destroy.dt.DTAF",function(){e.off("mousedown.DTAF").remove();c("tbody",this.dom.table).off("mouseover.DTAF mouseout.DTAF")})},_initColumns:function(){var d=this,b,a,e=this.s.dt,g=this.s.init;b=0;for(a=e.aoColumns.length;b<a;b++)this.s.columns[b]=c.extend(!0,{},h.defaults.column);e.oApi._fnApplyColumnDefs(e,g.aoColumnDefs||g.columnDefs,g.aoColumns||g.columns,function(a,b){d._fnColumnOptions(a,b)});b=0;for(a=e.aoColumns.length;b<
|
||||
a;b++)if(e=this.s.columns[b],e.read||(e.read=this._fnReadCell),e.write||(e.read=this._fnWriteCell),!e.step)e.read=this._fnStep},_fnColumnOptions:function(d,b){var a=this.s.columns[d],c=function(c,d){b[d[0]]!==m&&(a[c]=b[d[0]]);b[d[1]]!==m&&(a[c]=b[d[1]])};c("enable",["bEnable","enable"]);c("read",["fnRead","read"]);c("write",["fnWrite","write"]);c("step",["fnStep","step"]);c("increment",["bIncrement","increment"])},_fnTargetCoords:function(d){var b=c(d).parents("tr")[0],a=this.s.dt.oInstance.fnGetPosition(d);
|
||||
return{x:c("td",b).index(d),y:c("tr",b.parentNode).index(b),row:a[0],column:a[2]}},_fnUpdateBorder:function(d,b){var a=this.s.border.width,e=c(d).offset(),g=c(b).offset(),f=e.left-a,i=g.left+c(b).outerWidth(),n=e.top-a,h=g.top+c(b).outerHeight(),j=g.left+c(b).outerWidth()-e.left+2*a,k=g.top+c(b).outerHeight()-e.top+2*a;e.left>g.left&&(f=g.left-a,i=e.left+c(d).outerWidth(),j=e.left+c(d).outerWidth()-g.left+2*a);""!==this.s.dt.oScroll.sY&&(a=c(this.s.dt.nTable.parentNode).offset(),e=c(this.s.dt.nTable.parentNode).scrollTop(),
|
||||
g=c(this.s.dt.nTable.parentNode).scrollLeft(),f-=a.left-g,i-=a.left-g,n-=a.top-e,h-=a.top-e);a=this.dom.borderTop.style;a.top=n+"px";a.left=f+"px";a.height=this.s.border.width+"px";a.width=j+"px";a=this.dom.borderBottom.style;a.top=h+"px";a.left=f+"px";a.height=this.s.border.width+"px";a.width=j+"px";a=this.dom.borderLeft.style;a.top=n+"px";a.left=f+"px";a.height=k+"px";a.width=this.s.border.width+"px";a=this.dom.borderRight.style;a.top=n+"px";a.left=i+"px";a.height=k+"px";a.width=this.s.border.width+
|
||||
"px"},_fnFillerDragStart:function(d){var b=this,a=this.dom.currentTarget;this.s.drag.dragging=!0;b.dom.borderTop.style.display="block";b.dom.borderRight.style.display="block";b.dom.borderBottom.style.display="block";b.dom.borderLeft.style.display="block";var e=this._fnTargetCoords(a);this.s.drag.startX=e.x;this.s.drag.startY=e.y;this.s.drag.startTd=a;this.s.drag.endTd=a;this._fnUpdateBorder(a,a);c(j).bind("mousemove.AutoFill",function(a){b._fnFillerDragMove.call(b,a)});c(j).bind("mouseup.AutoFill",
|
||||
function(a){b._fnFillerFinish.call(b,a)});this.s.screen.y=d.pageY;this.s.screen.height=c(o).height();this.s.screen.scrollTop=c(j).scrollTop();""!==this.s.dt.oScroll.sY&&(this.s.scroller.top=c(this.s.dt.nTable.parentNode).offset().top,this.s.scroller.bottom=this.s.scroller.top+c(this.s.dt.nTable.parentNode).height());this.s.screen.interval=setInterval(function(){var a=c(j).scrollTop();b.s.screen.y=b.s.screen.y+(a-b.s.screen.scrollTop);b.s.screen.height-b.s.screen.y+a<50?c("html, body").animate({scrollTop:a+
|
||||
50},240,"linear"):b.s.screen.y-a<50&&c("html, body").animate({scrollTop:a-50},240,"linear");b.s.dt.oScroll.sY!==""&&(b.s.screen.y>b.s.scroller.bottom-50?c(b.s.dt.nTable.parentNode).animate({scrollTop:c(b.s.dt.nTable.parentNode).scrollTop()+50},240,"linear"):b.s.screen.y<b.s.scroller.top+50&&c(b.s.dt.nTable.parentNode).animate({scrollTop:c(b.s.dt.nTable.parentNode).scrollTop()-50},240,"linear"))},250)},_fnFillerDragMove:function(d){if(d.target&&"TD"==d.target.nodeName.toUpperCase()&&d.target!=this.s.drag.endTd){var b=
|
||||
this._fnTargetCoords(d.target);"y"==this.c.mode&&b.x!=this.s.drag.startX&&(d.target=c("tbody>tr:eq("+b.y+")>td:eq("+this.s.drag.startX+")",this.dom.table)[0]);"x"==this.c.mode&&b.y!=this.s.drag.startY&&(d.target=c("tbody>tr:eq("+this.s.drag.startY+")>td:eq("+b.x+")",this.dom.table)[0]);"either"==this.c.mode&&(b.x!=this.s.drag.startX?d.target=c("tbody>tr:eq("+this.s.drag.startY+")>td:eq("+b.x+")",this.dom.table)[0]:b.y!=this.s.drag.startY&&(d.target=c("tbody>tr:eq("+b.y+")>td:eq("+this.s.drag.startX+
|
||||
")",this.dom.table)[0]));"both"!==this.c.mode&&(b=this._fnTargetCoords(d.target));var a=this.s.drag;a.endTd=d.target;b.y>=this.s.drag.startY?this._fnUpdateBorder(a.startTd,a.endTd):this._fnUpdateBorder(a.endTd,a.startTd);this._fnFillerPosition(d.target)}this.s.screen.y=d.pageY;this.s.screen.scrollTop=c(j).scrollTop();""!==this.s.dt.oScroll.sY&&(this.s.scroller.scrollTop=c(this.s.dt.nTable.parentNode).scrollTop(),this.s.scroller.top=c(this.s.dt.nTable.parentNode).offset().top,this.s.scroller.bottom=
|
||||
this.s.scroller.top+c(this.s.dt.nTable.parentNode).height())},_fnFillerFinish:function(){var d=this,b,a;c(j).unbind("mousemove.AutoFill mouseup.AutoFill");this.dom.borderTop.style.display="none";this.dom.borderRight.style.display="none";this.dom.borderBottom.style.display="none";this.dom.borderLeft.style.display="none";this.s.drag.dragging=!1;clearInterval(this.s.screen.interval);var e=[],g=this.dom.table,f=this._fnTargetCoords(this.s.drag.startTd),i=this._fnTargetCoords(this.s.drag.endTd),h=function(a){return d.s.dt.oApi._fnVisibleToColumnIndex(d.s.dt,
|
||||
a)};if(f.y<=i.y)for(b=f.y;b<=i.y;b++)if(f.x<=i.x)for(a=f.x;a<=i.x;a++)e.push({node:c("tbody>tr:eq("+b+")>td:eq("+a+")",g)[0],x:a-f.x,y:b-f.y,colIdx:h(a)});else for(a=f.x;a>=i.x;a--)e.push({node:c("tbody>tr:eq("+b+")>td:eq("+a+")",g)[0],x:a-f.x,y:b-f.y,colIdx:h(a)});else for(b=f.y;b>=i.y;b--)if(f.x<=i.x)for(a=f.x;a<=i.x;a++)e.push({node:c("tbody>tr:eq("+b+")>td:eq("+a+")",g)[0],x:a-f.x,y:b-f.y,colIdx:h(a)});else for(a=f.x;a>=i.x;a--)e.push({node:c("tbody>tr:eq("+b+")>td:eq("+a+")",g)[0],x:f.x-a,y:f.y-
|
||||
b,colIdx:h(a)});if(!(1>=e.length)){var g=[],m;b=0;for(a=e.length;b<a;b++){var f=e[b],i=this.s.columns[f.colIdx],h=i.read.call(i,f.node),l=i.step.call(i,f.node,h,m,b,f.x,f.y);i.write.call(i,f.node,l);m=l;g.push({cell:f,colIdx:f.colIdx,newValue:l,oldValue:h})}null!==this.c.complete&&this.c.complete.call(this,g);k.Api?(new k.Api(this.s.dt)).draw(!1):this.s.dt.oInstance.fnDraw()}},_fnFillerDisplay:function(d){var b=this.dom.filler;if(!this.s.drag.dragging){var a="td"==d.target.nodeName.toLowerCase()?
|
||||
d.target:c(d.target).parents("td")[0],e=this._fnTargetCoords(a).column;if(this.s.columns[e].enable)if("mouseover"==d.type)this.dom.currentTarget=a,this._fnFillerPosition(a),b.style.display="block";else{if(!d.relatedTarget||!d.relatedTarget.className.match(/AutoFill/))b.style.display="none"}else b.style.display="none"}},_fnFillerPosition:function(d){var b=c(d).offset(),a=this.dom.filler;a.style.top=b.top-this.s.filler.height/2-1+c(d).outerHeight()+"px";a.style.left=b.left-this.s.filler.width/2-1+c(d).outerWidth()+
|
||||
"px"}};k.AutoFill=h;k.AutoFill=h;h.version="1.2.1";h.defaults={mode:"y",complete:null,column:{enable:!0,increment:!0,read:function(d){return c(d).html()},write:function(d,b){var a=c(d).parents("table");if(k.Api)a.DataTable().cell(d).data(b);else{var a=a.dataTable(),e=a.fnGetPosition(d);a.fnUpdate(b,e[0],e[2],!1)}},step:function(c,b,a,e,g,f){c=/(\-?\d+)/;return(e=this.increment&&a?a.match(c):null)?a.replace(c,parseInt(e[1],10)+(0>g||0>f?-1:1)):a===m?b:a}}};return h};"function"===typeof define&&define.amd?
|
||||
define(["jquery","datatables"],l):"object"===typeof exports?l(require("jquery"),require("datatables")):jQuery&&!jQuery.fn.dataTable.AutoFill&&l(jQuery,jQuery.fn.dataTable)})(window,document);
|
||||
(function(e){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(l){return e(l,window,document)}):"object"===typeof exports?module.exports=function(l,i){l||(l=window);if(!i||!i.fn.dataTable)i=require("datatables.net")(l,i).$;return e(i,l,l.document)}:e(jQuery,window,document)})(function(e,l,i,q){var k=e.fn.dataTable,o=0,j=function(c,b){if(!k.versionCheck||!k.versionCheck("1.10.8"))throw"Warning: AutoFill requires DataTables 1.10.8 or greater";this.c=e.extend(!0,{},k.defaults.autoFill,
|
||||
j.defaults,b);this.s={dt:new k.Api(c),namespace:".autoFill"+o++,scroll:{},scrollInterval:null,handle:{height:0,width:0}};this.dom={handle:e('<div class="dt-autofill-handle"/>'),select:{top:e('<div class="dt-autofill-select top"/>'),right:e('<div class="dt-autofill-select right"/>'),bottom:e('<div class="dt-autofill-select bottom"/>'),left:e('<div class="dt-autofill-select left"/>')},background:e('<div class="dt-autofill-background"/>'),list:e('<div class="dt-autofill-list">'+this.s.dt.i18n("autoFill.info",
|
||||
"")+"<ul/></div>"),dtScroll:null,offsetParent:null};this._constructor()};e.extend(j.prototype,{_constructor:function(){var c=this,b=this.s.dt,a=e("div.dataTables_scrollBody",this.s.dt.table().container());a.length&&(this.dom.dtScroll=a,"static"===a.css("position")&&a.css("position","relative"));this._focusListener();this.dom.handle.on("mousedown",function(a){c._mousedown(a);return false});b.on("destroy.autoFill",function(){b.off(".autoFill");e(b.table().body()).off(c.s.namespace);e(i.body).off(c.s.namespace)})},
|
||||
_attach:function(c){var b=this.s.dt,a=b.cell(c).index(),d=this.dom.handle,f=this.s.handle,g=e("div.dataTables_scrollBody",this.s.dt.table().container());if(!a||-1===b.columns(this.c.columns).indexes().indexOf(a.column))this._detach();else{this.dom.offsetParent||(this.dom.offsetParent=e(c).offsetParent());if(!f.height||!f.width)d.appendTo("body"),f.height=d.outerHeight(),f.width=d.outerWidth();b=e(c).position();this.dom.attachedTo=c;d.css({top:b.top+c.offsetHeight-f.height+g.scrollTop(),left:b.left+
|
||||
c.offsetWidth-f.width+g.scrollLeft()}).appendTo(this.dom.offsetParent)}},_actionSelector:function(c){var b=this,a=this.s.dt,d=j.actions,f=[];e.each(d,function(b,d){d.available(a,c)&&f.push(b)});if(1===f.length&&!1===this.c.alwaysAsk){var g=d[f[0]].execute(a,c);this._update(g,c)}else{var h=this.dom.list.children("ul").empty();f.push("cancel");e.each(f,function(f,g){h.append(e("<li/>").append('<div class="dt-autofill-question">'+d[g].option(a,c)+"<div>").append(e('<div class="dt-autofill-button">').append(e('<button class="'+
|
||||
j.classes.btn+'">'+a.i18n("autoFill.button",">")+"</button>").on("click",function(){var f=d[g].execute(a,c,e(this).closest("li"));b._update(f,c);b.dom.background.remove();b.dom.list.remove()}))))});this.dom.background.appendTo("body");this.dom.list.appendTo("body");this.dom.list.css("margin-top",-1*(this.dom.list.outerHeight()/2))}},_detach:function(){this.dom.attachedTo=null;this.dom.handle.detach()},_drawSelection:function(c){var b=this.s.dt,a=this.s.start,d=e(this.dom.start),f=e(c),g={row:b.rows({page:"current"}).nodes().indexOf(f.parent()[0]),
|
||||
column:f.index()};if(b.cell(f).any()&&-1!==b.columns(this.c.columns).indexes().indexOf(g.column)){this.s.end=g;var h,b=a.row<g.row?d:f;h=a.row<g.row?f:d;c=a.column<g.column?d:f;d=a.column<g.column?f:d;b=b.position().top;c=c.position().left;a=h.position().top+h.outerHeight()-b;d=d.position().left+d.outerWidth()-c;if(f=this.dom.dtScroll)b+=f.scrollTop(),c+=f.scrollLeft();f=this.dom.select;f.top.css({top:b,left:c,width:d});f.left.css({top:b,left:c,height:a});f.bottom.css({top:b+a,left:c,width:d});f.right.css({top:b,
|
||||
left:c+d,height:a})}},_editor:function(c){var b=this.s.dt,a=this.c.editor;if(a){for(var d={},f=[],e=a.fields(),h=0,i=c.length;h<i;h++)for(var j=0,l=c[h].length;j<l;j++){var n=c[h][j],k=b.settings()[0].aoColumns[n.index.column],m=k.editField;if(m===q)for(var k=k.mData,p=0,o=e.length;p<o;p++){var r=a.field(e[p]);if(r.dataSrc()===k){m=r.name();break}}if(!m)throw"Could not automatically determine field data. Please see https://datatables.net/tn/11";d[m]||(d[m]={});k=b.row(n.index.row).id();d[m][k]=n.set;
|
||||
f.push(n.index)}a.bubble(f,!1).multiSet(d).submit()}},_emitEvent:function(c,b){this.s.dt.iterator("table",function(a){e(a.nTable).triggerHandler(c+".dt",b)})},_focusListener:function(){var c=this,b=this.s.dt,a=this.s.namespace,d=null!==this.c.focus?this.c.focus:b.settings()[0].keytable?"focus":"hover";if("focus"===d)b.on("key-focus.autoFill",function(a,b,d){c._attach(d.node())}).on("key-blur.autoFill",function(){c._detach()});else if("click"===d)e(b.table().body()).on("click"+a,"td, th",function(){c._attach(this)}),
|
||||
e(i.body).on("click"+a,function(a){e(a.target).parents().filter(b.table().body()).length||c._detach()});else e(b.table().body()).on("mouseenter"+a,"td, th",function(){c._attach(this)}).on("mouseleave"+a,function(a){e(a.relatedTarget).hasClass("dt-autofill-handle")||c._detach()})},_mousedown:function(c){var b=this,a=this.s.dt;this.dom.start=this.dom.attachedTo;this.s.start={row:a.rows({page:"current"}).nodes().indexOf(e(this.dom.start).parent()[0]),column:e(this.dom.start).index()};e(i.body).on("mousemove.autoFill",
|
||||
function(a){b._mousemove(a)}).on("mouseup.autoFill",function(a){b._mouseup(a)});var a=this.dom.select,d=e(this.s.dt.table().body()).offsetParent();a.top.appendTo(d);a.left.appendTo(d);a.right.appendTo(d);a.bottom.appendTo(d);this._drawSelection(this.dom.start,c);this.dom.handle.css("display","none");c=this.dom.dtScroll;this.s.scroll={windowHeight:e(l).height(),windowWidth:e(l).width(),dtTop:c?c.offset().top:null,dtLeft:c?c.offset().left:null,dtHeight:c?c.outerHeight():null,dtWidth:c?c.outerWidth():
|
||||
null}},_mousemove:function(c){var b=c.target.nodeName.toLowerCase();"td"!==b&&"th"!==b||(this._drawSelection(c.target,c),this._shiftScroll(c))},_mouseup:function(){e(i.body).off(".autoFill");var c=this.s.dt,b=this.dom.select;b.top.remove();b.left.remove();b.right.remove();b.bottom.remove();this.dom.handle.css("display","block");var b=this.s.start,a=this.s.end;if(!(b.row===a.row&&b.column===a.column)){for(var d=this._range(b.row,a.row),b=this._range(b.column,a.column),a=[],f=c.settings()[0],g=f.aoColumns,
|
||||
h=0;h<d.length;h++)a.push(e.map(b,function(a){var a=c.cell(":eq("+d[h]+")",a+":visible",{page:"current"}),b=a.data(),e=a.index(),i=g[e.column].editField;i!==q&&(b=f.oApi._fnGetObjectDataFn(i)(c.row(e.row).data()));return{cell:a,data:b,label:a.data(),index:e}}));this._actionSelector(a);clearInterval(this.s.scrollInterval);this.s.scrollInterval=null}},_range:function(c,b){var a=[],d;if(c<=b)for(d=c;d<=b;d++)a.push(d);else for(d=c;d>=b;d--)a.push(d);return a},_shiftScroll:function(c){var b=this,a=this.s.scroll,
|
||||
d=!1,f=c.pageY-i.body.scrollTop,e=c.pageX-i.body.scrollLeft,h,j,k,l;65>f?h=-5:f>a.windowHeight-65&&(h=5);65>e?j=-5:e>a.windowWidth-65&&(j=5);null!==a.dtTop&&c.pageY<a.dtTop+65?k=-5:null!==a.dtTop&&c.pageY>a.dtTop+a.dtHeight-65&&(k=5);null!==a.dtLeft&&c.pageX<a.dtLeft+65?l=-5:null!==a.dtLeft&&c.pageX>a.dtLeft+a.dtWidth-65&&(l=5);h||j||k||l?(a.windowVert=h,a.windowHoriz=j,a.dtVert=k,a.dtHoriz=l,d=!0):this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null);!this.s.scrollInterval&&
|
||||
d&&(this.s.scrollInterval=setInterval(function(){if(a.windowVert)i.body.scrollTop=i.body.scrollTop+a.windowVert;if(a.windowHoriz)i.body.scrollLeft=i.body.scrollLeft+a.windowHoriz;if(a.dtVert||a.dtHoriz){var c=b.dom.dtScroll[0];if(a.dtVert)c.scrollTop=c.scrollTop+a.dtVert;if(a.dtHoriz)c.scrollLeft=c.scrollLeft+a.dtHoriz}},20))},_update:function(c,b){if(!1!==c){var a=this.s.dt,d;this._emitEvent("preAutoFill",[a,b]);this._editor(b);if(null!==this.c.update?this.c.update:!this.c.editor){for(var f=0,e=
|
||||
b.length;f<e;f++)for(var h=0,i=b[f].length;h<i;h++)d=b[f][h],d.cell.data(d.set);a.draw(!1)}this._emitEvent("autoFill",[a,b])}}});j.actions={increment:{available:function(c,b){return e.isNumeric(b[0][0].label)},option:function(c){return c.i18n("autoFill.increment",'Increment / decrement each cell by: <input type="number" value="1">')},execute:function(c,b,a){for(var c=1*b[0][0].data,a=1*e("input",a).val(),d=0,f=b.length;d<f;d++)for(var g=0,h=b[d].length;g<h;g++)b[d][g].set=c,c+=a}},fill:{available:function(){return!0},
|
||||
option:function(c,b){return c.i18n("autoFill.fill","Fill all cells with <i>"+b[0][0].label+"</i>")},execute:function(c,b){for(var a=b[0][0].data,d=0,e=b.length;d<e;d++)for(var g=0,h=b[d].length;g<h;g++)b[d][g].set=a}},fillHorizontal:{available:function(c,b){return 1<b.length&&1<b[0].length},option:function(c){return c.i18n("autoFill.fillHorizontal","Fill cells horizontally")},execute:function(c,b){for(var a=0,d=b.length;a<d;a++)for(var e=0,g=b[a].length;e<g;e++)b[a][e].set=b[a][0].data}},fillVertical:{available:function(c,
|
||||
b){return 1<b.length&&1<b[0].length},option:function(c){return c.i18n("autoFill.fillVertical","Fill cells vertically")},execute:function(c,b){for(var a=0,d=b.length;a<d;a++)for(var e=0,g=b[a].length;e<g;e++)b[a][e].set=b[0][e].data}},cancel:{available:function(){return!1},option:function(c){return c.i18n("autoFill.cancel","Cancel")},execute:function(){return!1}}};j.version="2.1.1";j.defaults={alwaysAsk:!1,focus:null,columns:"",update:null,editor:null};j.classes={btn:"btn"};e(i).on("preInit.dt.autofill",
|
||||
function(c,b){if("dt"===c.namespace){var a=b.oInit.autoFill,d=k.defaults.autoFill;if(a||d)d=e.extend({},a,d),!1!==a&&new j(b,d)}});k.AutoFill=j;return k.AutoFill=j});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
MIT license
|
||||
|
||||
Copyright (c) 2010-2015 SpryMedia Limited
|
||||
http://datatables.net
|
||||
|
||||
|
||||
@@ -1,39 +1,35 @@
|
||||
# ColReorder
|
||||
|
||||
ColReorder adds the ability for the end user to click and drag column headers to reorder a table as they see fit, to DataTables. Key features include:
|
||||
|
||||
* Very easy integration with DataTables
|
||||
* Tight integration with all other DataTables plug-ins
|
||||
* The ability to exclude the first (or more) column from being movable
|
||||
* Predefine a column order
|
||||
* Save staving integration with DataTables
|
||||
ColReorder adds the ability for the end user to click and drag column headers to reorder a table as they see fit, to DataTables. See the [documentation](http://datatables.net/extensions/colreorder/) for full details.
|
||||
|
||||
|
||||
# Installation
|
||||
|
||||
To use ColReorder, first download DataTables ( http://datatables.net/download ) and place the unzipped ColReorder package into a `extensions` directory in the DataTables package. This will allow the pages in the examples to operate correctly. To see the examples running, open the `examples` directory in your web-browser.
|
||||
To use ColReorder the primary way to obtain the software is to use the [DataTables downloader](//datatables.net/download). You can also include the individual files from the [DataTables CDN](//cdn.datatables.net). See the [documentation](http://datatables.net/extensions/colreorder/) for full details.
|
||||
|
||||
## NPM and Bower
|
||||
|
||||
If you prefer to use a package manager such as NPM or Bower, distribution repositories are available with software built from this repository under the name `datatables.net-colreorder`. Styling packages for Bootstrap, Foundation and other styling libraries are also available by adding a suffix to the package name.
|
||||
|
||||
Please see the DataTables [NPM](//datatables.net/download/npm) and [Bower](//datatables.net/download/bower) installation pages for further information. The [DataTables installation manual](//datatables.net/manual/installation) also has details on how to use package managers with DataTables.
|
||||
|
||||
|
||||
# Basic usage
|
||||
|
||||
ColReorder is initialised using the `$.fn.dataTable.ColReorder` constructor. For example:
|
||||
ColReorder is initialised using the `colReorder` option in the DataTables constructor - a simple boolean `true` will enable the feature. Further options can be specified using this option as an object - see the documentation for details.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
$(document).ready( function () {
|
||||
$('#example').DataTable();
|
||||
|
||||
new $.fn.dataTable.ColReorder( table );
|
||||
$('#myTable').DataTable( {
|
||||
colReorder: true
|
||||
} );
|
||||
} );
|
||||
```
|
||||
|
||||
|
||||
# Documentation / support
|
||||
|
||||
* Documentation: http://datatables.net/extensions/colreorder/
|
||||
* DataTables support forums: http://datatables.net/forums
|
||||
|
||||
|
||||
# GitHub
|
||||
|
||||
If you fancy getting involved with the development of ColReorder and help make it better, please refer to its GitHub repo: https://github.com/DataTables/ColReorder
|
||||
|
||||
* [Documentation](https://datatables.net/extensions/colreorder/)
|
||||
* [DataTables support forums](http://datatables.net/forums)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*! ColReorder 1.1.3
|
||||
* ©2010-2014 SpryMedia Ltd - datatables.net/license
|
||||
/*! ColReorder 1.3.1
|
||||
* ©2010-2015 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @summary ColReorder
|
||||
* @description Provide the ability to reorder columns in a DataTable
|
||||
* @version 1.1.3
|
||||
* @version 1.3.1
|
||||
* @file dataTables.colReorder.js
|
||||
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
||||
* @contact www.sprymedia.co.uk/contact
|
||||
@@ -20,8 +20,34 @@
|
||||
*
|
||||
* For details please refer to: http://www.datatables.net
|
||||
*/
|
||||
(function( factory ){
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( ['jquery', 'datatables.net'], function ( $ ) {
|
||||
return factory( $, window, document );
|
||||
} );
|
||||
}
|
||||
else if ( typeof exports === 'object' ) {
|
||||
// CommonJS
|
||||
module.exports = function (root, $) {
|
||||
if ( ! root ) {
|
||||
root = window;
|
||||
}
|
||||
|
||||
(function(window, document, undefined) {
|
||||
if ( ! $ || ! $.fn.dataTable ) {
|
||||
$ = require('datatables.net')(root, $).$;
|
||||
}
|
||||
|
||||
return factory( $, root, root.document );
|
||||
};
|
||||
}
|
||||
else {
|
||||
// Browser
|
||||
factory( jQuery, window, document );
|
||||
}
|
||||
}(function( $, window, document, undefined ) {
|
||||
'use strict';
|
||||
var DataTable = $.fn.dataTable;
|
||||
|
||||
|
||||
/**
|
||||
@@ -89,10 +115,6 @@ function fnDomSwitch( nParent, iFrom, iTo )
|
||||
}
|
||||
|
||||
|
||||
|
||||
var factory = function( $, DataTable ) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Plug-in for DataTables which will reorder the internal column structure by taking the column
|
||||
* from one position (iFrom) and insert it into a given point (iTo).
|
||||
@@ -100,14 +122,15 @@ var factory = function( $, DataTable ) {
|
||||
* @param object oSettings DataTables settings object - automatically added by DataTables!
|
||||
* @param int iFrom Take the column to be repositioned from this point
|
||||
* @param int iTo and insert it into this point
|
||||
* @param bool drop Indicate if the reorder is the final one (i.e. a drop)
|
||||
* not a live reorder
|
||||
* @returns void
|
||||
*/
|
||||
$.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
||||
$.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo, drop )
|
||||
{
|
||||
var v110 = $.fn.dataTable.Api ? true : false;
|
||||
var i, iLen, j, jLen, iCols=oSettings.aoColumns.length, nTrs, oCol;
|
||||
var i, iLen, j, jLen, jen, iCols=oSettings.aoColumns.length, nTrs, oCol;
|
||||
var attrMap = function ( obj, prop, mapping ) {
|
||||
if ( ! obj[ prop ] ) {
|
||||
if ( ! obj[ prop ] || typeof obj[ prop ] === 'function' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -180,17 +203,13 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
||||
}
|
||||
|
||||
// Update the column indexes
|
||||
if ( v110 ) {
|
||||
oCol.idx = aiInvertMapping[ oCol.idx ];
|
||||
}
|
||||
oCol.idx = aiInvertMapping[ oCol.idx ];
|
||||
}
|
||||
|
||||
if ( v110 ) {
|
||||
// Update 1.10 optimised sort class removal variable
|
||||
$.each( oSettings.aLastSort, function (i, val) {
|
||||
oSettings.aLastSort[i].src = aiInvertMapping[ val.src ];
|
||||
} );
|
||||
}
|
||||
// Update 1.10 optimised sort class removal variable
|
||||
$.each( oSettings.aLastSort, function (i, val) {
|
||||
oSettings.aLastSort[i].src = aiInvertMapping[ val.src ];
|
||||
} );
|
||||
|
||||
/* Update the Get and Set functions for each column */
|
||||
for ( i=0, iLen=iCols ; i<iLen ; i++ )
|
||||
@@ -199,9 +218,6 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
||||
|
||||
if ( typeof oCol.mData == 'number' ) {
|
||||
oCol.mData = aiInvertMapping[ oCol.mData ];
|
||||
|
||||
// regenerate the get / set functions
|
||||
oSettings.oApi._fnColumnOptions( oSettings, i, {} );
|
||||
}
|
||||
else if ( $.isPlainObject( oCol.mData ) ) {
|
||||
// HTML5 data sourced
|
||||
@@ -209,13 +225,9 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
||||
attrMap( oCol.mData, 'filter', aiInvertMapping );
|
||||
attrMap( oCol.mData, 'sort', aiInvertMapping );
|
||||
attrMap( oCol.mData, 'type', aiInvertMapping );
|
||||
|
||||
// regenerate the get / set functions
|
||||
oSettings.oApi._fnColumnOptions( oSettings, i, {} );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Move the DOM elements
|
||||
*/
|
||||
@@ -268,6 +280,11 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
||||
/* Columns */
|
||||
fnArraySwitch( oSettings.aoColumns, iFrom, iTo );
|
||||
|
||||
// regenerate the get / set functions
|
||||
for ( i=0, iLen=iCols ; i<iLen ; i++ ) {
|
||||
oSettings.oApi._fnColumnOptions( oSettings, i, {} );
|
||||
}
|
||||
|
||||
/* Search columns */
|
||||
fnArraySwitch( oSettings.aoPreSearchCols, iFrom, iTo );
|
||||
|
||||
@@ -275,26 +292,25 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
||||
for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
|
||||
{
|
||||
var data = oSettings.aoData[i];
|
||||
var cells = data.anCells;
|
||||
|
||||
if ( v110 ) {
|
||||
// DataTables 1.10+
|
||||
if ( data.anCells ) {
|
||||
fnArraySwitch( data.anCells, iFrom, iTo );
|
||||
}
|
||||
if ( cells ) {
|
||||
fnArraySwitch( cells, iFrom, iTo );
|
||||
|
||||
// For DOM sourced data, the invalidate will reread the cell into
|
||||
// the data array, but for data sources as an array, they need to
|
||||
// be flipped
|
||||
if ( data.src !== 'dom' && $.isArray( data._aData ) ) {
|
||||
fnArraySwitch( data._aData, iFrom, iTo );
|
||||
// Longer term, should this be moved into the DataTables' invalidate
|
||||
// methods?
|
||||
for ( j=0, jen=cells.length ; j<jen ; j++ ) {
|
||||
if ( cells[j] && cells[j]._DT_CellIndex ) {
|
||||
cells[j]._DT_CellIndex.column = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// DataTables 1.9-
|
||||
if ( $.isArray( data._aData ) ) {
|
||||
fnArraySwitch( data._aData, iFrom, iTo );
|
||||
}
|
||||
fnArraySwitch( data._anHidden, iFrom, iTo );
|
||||
|
||||
// For DOM sourced data, the invalidate will reread the cell into
|
||||
// the data array, but for data sources as an array, they need to
|
||||
// be flipped
|
||||
if ( data.src !== 'dom' && $.isArray( data._aData ) ) {
|
||||
fnArraySwitch( data._aData, iFrom, iTo );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,11 +328,9 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
||||
}
|
||||
}
|
||||
|
||||
// In 1.10 we need to invalidate row cached data for sorting, filtering etc
|
||||
if ( v110 ) {
|
||||
var api = new $.fn.dataTable.Api( oSettings );
|
||||
api.rows().invalidate();
|
||||
}
|
||||
// Invalidate row cached data for sorting, filtering etc
|
||||
var api = new $.fn.dataTable.Api( oSettings );
|
||||
api.rows().invalidate();
|
||||
|
||||
/*
|
||||
* Update DataTables' event handlers
|
||||
@@ -331,10 +345,16 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
||||
|
||||
|
||||
/* Fire an event so other plug-ins can update */
|
||||
$(oSettings.oInstance).trigger( 'column-reorder', [ oSettings, {
|
||||
"iFrom": iFrom,
|
||||
"iTo": iTo,
|
||||
"aiInvertMapping": aiInvertMapping
|
||||
$(oSettings.oInstance).trigger( 'column-reorder.dt', [ oSettings, {
|
||||
from: iFrom,
|
||||
to: iTo,
|
||||
mapping: aiInvertMapping,
|
||||
drop: drop,
|
||||
|
||||
// Old style parameters for compatibility
|
||||
iFrom: iFrom,
|
||||
iTo: iTo,
|
||||
aiInvertMapping: aiInvertMapping
|
||||
} ] );
|
||||
};
|
||||
|
||||
@@ -348,42 +368,16 @@ $.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
|
||||
*/
|
||||
var ColReorder = function( dt, opts )
|
||||
{
|
||||
var oDTSettings;
|
||||
|
||||
if ( $.fn.dataTable.Api ) {
|
||||
oDTSettings = new $.fn.dataTable.Api( dt ).settings()[0];
|
||||
}
|
||||
// 1.9 compatibility
|
||||
else if ( dt.fnSettings ) {
|
||||
// DataTables object, convert to the settings object
|
||||
oDTSettings = dt.fnSettings();
|
||||
}
|
||||
else if ( typeof dt === 'string' ) {
|
||||
// jQuery selector
|
||||
if ( $.fn.dataTable.fnIsDataTable( $(dt)[0] ) ) {
|
||||
oDTSettings = $(dt).eq(0).dataTable().fnSettings();
|
||||
}
|
||||
}
|
||||
else if ( dt.nodeName && dt.nodeName.toLowerCase() === 'table' ) {
|
||||
// Table node
|
||||
if ( $.fn.dataTable.fnIsDataTable( dt.nodeName ) ) {
|
||||
oDTSettings = $(dt.nodeName).dataTable().fnSettings();
|
||||
}
|
||||
}
|
||||
else if ( dt instanceof jQuery ) {
|
||||
// jQuery object
|
||||
if ( $.fn.dataTable.fnIsDataTable( dt[0] ) ) {
|
||||
oDTSettings = dt.eq(0).dataTable().fnSettings();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// DataTables settings object
|
||||
oDTSettings = dt;
|
||||
}
|
||||
var settings = new $.fn.dataTable.Api( dt ).settings()[0];
|
||||
|
||||
// Ensure that we can't initialise on the same table twice
|
||||
if ( oDTSettings._colReorder ) {
|
||||
throw "ColReorder already initialised on table #"+oDTSettings.nTable.id;
|
||||
if ( settings._colReorder ) {
|
||||
return settings._colReorder;
|
||||
}
|
||||
|
||||
// Allow the options to be a boolean for defaults
|
||||
if ( opts === true ) {
|
||||
opts = {};
|
||||
}
|
||||
|
||||
// Convert from camelCase to Hungarian, just as DataTables does
|
||||
@@ -491,19 +485,16 @@ var ColReorder = function( dt, opts )
|
||||
|
||||
|
||||
/* Constructor logic */
|
||||
this.s.dt = oDTSettings;
|
||||
this.s.dt = settings;
|
||||
this.s.dt._colReorder = this;
|
||||
this._fnConstruct();
|
||||
|
||||
/* Add destroy callback */
|
||||
oDTSettings.oApi._fnCallbackReg(oDTSettings, 'aoDestroyCallback', $.proxy(this._fnDestroy, this), 'ColReorder');
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
|
||||
ColReorder.prototype = {
|
||||
$.extend( ColReorder.prototype, {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
@@ -527,13 +518,7 @@ ColReorder.prototype = {
|
||||
*/
|
||||
"fnReset": function ()
|
||||
{
|
||||
var a = [];
|
||||
for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
|
||||
{
|
||||
a.push( this.s.dt.aoColumns[i]._ColReorder_iOrigCol );
|
||||
}
|
||||
|
||||
this._fnOrderColumns( a );
|
||||
this._fnOrderColumns( this.fnOrder() );
|
||||
|
||||
return this;
|
||||
},
|
||||
@@ -585,24 +570,74 @@ ColReorder.prototype = {
|
||||
* $.fn.dataTable.ColReorder( '#example' ).fnOrder().reverse()
|
||||
* );
|
||||
*/
|
||||
"fnOrder": function ( set )
|
||||
"fnOrder": function ( set, original )
|
||||
{
|
||||
if ( set === undefined )
|
||||
{
|
||||
var a = [];
|
||||
for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
|
||||
{
|
||||
a.push( this.s.dt.aoColumns[i]._ColReorder_iOrigCol );
|
||||
var a = [], i, ien, j, jen;
|
||||
var columns = this.s.dt.aoColumns;
|
||||
|
||||
if ( set === undefined ){
|
||||
for ( i=0, ien=columns.length ; i<ien ; i++ ) {
|
||||
a.push( columns[i]._ColReorder_iOrigCol );
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
// The order given is based on the original indexes, rather than the
|
||||
// existing ones, so we need to translate from the original to current
|
||||
// before then doing the order
|
||||
if ( original ) {
|
||||
var order = this.fnOrder();
|
||||
|
||||
for ( i=0, ien=set.length ; i<ien ; i++ ) {
|
||||
a.push( $.inArray( set[i], order ) );
|
||||
}
|
||||
|
||||
set = a;
|
||||
}
|
||||
|
||||
this._fnOrderColumns( fnInvertKeyValues( set ) );
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Convert from the original column index, to the original
|
||||
*
|
||||
* @param {int|array} idx Index(es) to convert
|
||||
* @param {string} dir Transpose direction - `fromOriginal` / `toCurrent`
|
||||
* or `'toOriginal` / `fromCurrent`
|
||||
* @return {int|array} Converted values
|
||||
*/
|
||||
fnTranspose: function ( idx, dir )
|
||||
{
|
||||
if ( ! dir ) {
|
||||
dir = 'toCurrent';
|
||||
}
|
||||
|
||||
var order = this.fnOrder();
|
||||
var columns = this.s.dt.aoColumns;
|
||||
|
||||
if ( dir === 'toCurrent' ) {
|
||||
// Given an original index, want the current
|
||||
return ! $.isArray( idx ) ?
|
||||
$.inArray( idx, order ) :
|
||||
$.map( idx, function ( index ) {
|
||||
return $.inArray( index, order );
|
||||
} );
|
||||
}
|
||||
else {
|
||||
// Given a current index, want the original
|
||||
return ! $.isArray( idx ) ?
|
||||
columns[idx]._ColReorder_iOrigCol :
|
||||
$.map( idx, function ( index ) {
|
||||
return columns[index]._ColReorder_iOrigCol;
|
||||
} );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private methods (they are of course public in JS, but recommended as private)
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
@@ -617,6 +652,7 @@ ColReorder.prototype = {
|
||||
{
|
||||
var that = this;
|
||||
var iLen = this.s.dt.aoColumns.length;
|
||||
var table = this.s.dt.nTable;
|
||||
var i;
|
||||
|
||||
/* Columns discounted from reordering - counting left to right */
|
||||
@@ -625,6 +661,11 @@ ColReorder.prototype = {
|
||||
this.s.fixed = this.s.init.iFixedColumns;
|
||||
}
|
||||
|
||||
if ( this.s.init.iFixedColumnsLeft )
|
||||
{
|
||||
this.s.fixed = this.s.init.iFixedColumnsLeft;
|
||||
}
|
||||
|
||||
/* Columns discounted from reordering - counting right to left */
|
||||
this.s.fixedRight = this.s.init.iFixedColumnsRight ?
|
||||
this.s.init.iFixedColumnsRight :
|
||||
@@ -676,16 +717,13 @@ ColReorder.prototype = {
|
||||
if ( !that.s.dt._bInitComplete )
|
||||
{
|
||||
var bDone = false;
|
||||
this.s.dt.aoDrawCallback.push( {
|
||||
"fn": function () {
|
||||
if ( !that.s.dt._bInitComplete && !bDone )
|
||||
{
|
||||
bDone = true;
|
||||
var resort = fnInvertKeyValues( aiOrder );
|
||||
that._fnOrderColumns.call( that, resort );
|
||||
}
|
||||
},
|
||||
"sName": "ColReorder_Pre"
|
||||
$(table).on( 'draw.dt.colReorder', function () {
|
||||
if ( !that.s.dt._bInitComplete && !bDone )
|
||||
{
|
||||
bDone = true;
|
||||
var resort = fnInvertKeyValues( aiOrder );
|
||||
that._fnOrderColumns.call( that, resort );
|
||||
}
|
||||
} );
|
||||
}
|
||||
else
|
||||
@@ -697,6 +735,19 @@ ColReorder.prototype = {
|
||||
else {
|
||||
this._fnSetColumnIndexes();
|
||||
}
|
||||
|
||||
// Destroy clean up
|
||||
$(table).on( 'destroy.dt.colReorder', function () {
|
||||
$(table).off( 'destroy.dt.colReorder draw.dt.colReorder' );
|
||||
$(that.s.dt.nTHead).find( '*' ).off( '.ColReorder' );
|
||||
|
||||
$.each( that.s.dt.aoColumns, function (i, column) {
|
||||
$(column.nTh).removeAttr('data-column-index');
|
||||
} );
|
||||
|
||||
that.s.dt._colReorder = null;
|
||||
that.s = null;
|
||||
} );
|
||||
},
|
||||
|
||||
|
||||
@@ -709,6 +760,8 @@ ColReorder.prototype = {
|
||||
*/
|
||||
"_fnOrderColumns": function ( a )
|
||||
{
|
||||
var changed = false;
|
||||
|
||||
if ( a.length != this.s.dt.aoColumns.length )
|
||||
{
|
||||
this.s.dt.oInstance.oApi._fnLog( this.s.dt, 1, "ColReorder - array reorder does not "+
|
||||
@@ -725,10 +778,19 @@ ColReorder.prototype = {
|
||||
fnArraySwitch( a, currIndex, i );
|
||||
|
||||
/* Do the column reorder in the table */
|
||||
this.s.dt.oInstance.fnColReorder( currIndex, i );
|
||||
this.s.dt.oInstance.fnColReorder( currIndex, i, true );
|
||||
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
this._fnSetColumnIndexes();
|
||||
|
||||
// Has anything actually changed? If not, then nothing else to do
|
||||
if ( ! changed ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* When scrolling we need to recalculate the column sizes to allow for the shift */
|
||||
if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )
|
||||
{
|
||||
@@ -737,8 +799,6 @@ ColReorder.prototype = {
|
||||
|
||||
/* Save the state */
|
||||
this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
|
||||
|
||||
this._fnSetColumnIndexes();
|
||||
|
||||
if ( this.s.reorderCallback !== null )
|
||||
{
|
||||
@@ -930,7 +990,7 @@ ColReorder.prototype = {
|
||||
|
||||
// Perform reordering if realtime updating is on and the column has moved
|
||||
if ( this.s.init.bRealtime && lastToIndex !== this.s.mouse.toIndex ) {
|
||||
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
|
||||
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex, false );
|
||||
this.s.mouse.fromIndex = this.s.mouse.toIndex;
|
||||
this._fnRegions();
|
||||
}
|
||||
@@ -959,7 +1019,7 @@ ColReorder.prototype = {
|
||||
this.dom.pointer = null;
|
||||
|
||||
/* Actually do the reorder */
|
||||
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
|
||||
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex, true );
|
||||
this._fnSetColumnIndexes();
|
||||
|
||||
/* When scrolling we need to recalculate the column sizes to allow for the shift */
|
||||
@@ -998,10 +1058,12 @@ ColReorder.prototype = {
|
||||
} );
|
||||
|
||||
var iToPoint = 0;
|
||||
var total = $(aoColumns[0].nTh).offset().left; // Offset of the first column
|
||||
|
||||
for ( var i=0, iLen=aoColumns.length ; i<iLen ; i++ )
|
||||
{
|
||||
/* For the column / header in question, we want it's position to remain the same if the
|
||||
* position is just to it's immediate left or right, so we only incremement the counter for
|
||||
* position is just to it's immediate left or right, so we only increment the counter for
|
||||
* other columns
|
||||
*/
|
||||
if ( i != this.s.mouse.fromIndex )
|
||||
@@ -1009,10 +1071,12 @@ ColReorder.prototype = {
|
||||
iToPoint++;
|
||||
}
|
||||
|
||||
if ( aoColumns[i].bVisible )
|
||||
if ( aoColumns[i].bVisible && aoColumns[i].nTh.style.display !=='none' )
|
||||
{
|
||||
total += $(aoColumns[i].nTh).outerWidth();
|
||||
|
||||
this.s.aoTargets.push( {
|
||||
"x": $(aoColumns[i].nTh).offset().left + $(aoColumns[i].nTh).outerWidth(),
|
||||
"x": total,
|
||||
"to": iToPoint
|
||||
} );
|
||||
}
|
||||
@@ -1084,35 +1148,6 @@ ColReorder.prototype = {
|
||||
.appendTo( 'body' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Clean up ColReorder memory references and event handlers
|
||||
* @method _fnDestroy
|
||||
* @returns void
|
||||
* @private
|
||||
*/
|
||||
"_fnDestroy": function ()
|
||||
{
|
||||
var i, iLen;
|
||||
|
||||
for ( i=0, iLen=this.s.dt.aoDrawCallback.length ; i<iLen ; i++ )
|
||||
{
|
||||
if ( this.s.dt.aoDrawCallback[i].sName === 'ColReorder_Pre' )
|
||||
{
|
||||
this.s.dt.aoDrawCallback.splice( i, 1 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$(this.s.dt.nTHead).find( '*' ).off( '.ColReorder' );
|
||||
|
||||
$.each( this.s.dt.aoColumns, function (i, column) {
|
||||
$(column.nTh).removeAttr('data-column-index');
|
||||
} );
|
||||
|
||||
this.s.dt._colReorder = null;
|
||||
this.s = null;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Add a data attribute to the column headers, so we know the index of
|
||||
@@ -1126,7 +1161,7 @@ ColReorder.prototype = {
|
||||
$(column.nTh).attr('data-column-index', i);
|
||||
} );
|
||||
}
|
||||
};
|
||||
} );
|
||||
|
||||
|
||||
|
||||
@@ -1150,22 +1185,6 @@ ColReorder.defaults = {
|
||||
* @type array
|
||||
* @default null
|
||||
* @static
|
||||
* @example
|
||||
* // Using the `oColReorder` option in the DataTables options object
|
||||
* $('#example').dataTable( {
|
||||
* "sDom": 'Rlfrtip',
|
||||
* "oColReorder": {
|
||||
* "aiOrder": [ 4, 3, 2, 1, 0 ]
|
||||
* }
|
||||
* } );
|
||||
*
|
||||
* @example
|
||||
* // Using `new` constructor
|
||||
* $('#example').dataTable()
|
||||
*
|
||||
* new $.fn.dataTable.ColReorder( '#example', {
|
||||
* "aiOrder": [ 4, 3, 2, 1, 0 ]
|
||||
* } );
|
||||
*/
|
||||
aiOrder: null,
|
||||
|
||||
@@ -1178,24 +1197,8 @@ ColReorder.defaults = {
|
||||
* @type boolean
|
||||
* @default false
|
||||
* @static
|
||||
* @example
|
||||
* // Using the `oColReorder` option in the DataTables options object
|
||||
* $('#example').dataTable( {
|
||||
* "sDom": 'Rlfrtip',
|
||||
* "oColReorder": {
|
||||
* "bRealtime": true
|
||||
* }
|
||||
* } );
|
||||
*
|
||||
* @example
|
||||
* // Using `new` constructor
|
||||
* $('#example').dataTable()
|
||||
*
|
||||
* new $.fn.dataTable.ColReorder( '#example', {
|
||||
* "bRealtime": true
|
||||
* } );
|
||||
*/
|
||||
bRealtime: false,
|
||||
bRealtime: true,
|
||||
|
||||
/**
|
||||
* Indicate how many columns should be fixed in position (counting from the
|
||||
@@ -1203,74 +1206,23 @@ ColReorder.defaults = {
|
||||
* @type int
|
||||
* @default 0
|
||||
* @static
|
||||
* @example
|
||||
* // Using the `oColReorder` option in the DataTables options object
|
||||
* $('#example').dataTable( {
|
||||
* "sDom": 'Rlfrtip',
|
||||
* "oColReorder": {
|
||||
* "iFixedColumns": 1
|
||||
* }
|
||||
* } );
|
||||
*
|
||||
* @example
|
||||
* // Using `new` constructor
|
||||
* $('#example').dataTable()
|
||||
*
|
||||
* new $.fn.dataTable.ColReorder( '#example', {
|
||||
* "iFixedColumns": 1
|
||||
* } );
|
||||
*/
|
||||
iFixedColumns: 0,
|
||||
iFixedColumnsLeft: 0,
|
||||
|
||||
/**
|
||||
* As `iFixedColumnsRight` but counting from the right.
|
||||
* @type int
|
||||
* @default 0
|
||||
* @static
|
||||
* @example
|
||||
* // Using the `oColReorder` option in the DataTables options object
|
||||
* $('#example').dataTable( {
|
||||
* "sDom": 'Rlfrtip',
|
||||
* "oColReorder": {
|
||||
* "iFixedColumnsRight": 1
|
||||
* }
|
||||
* } );
|
||||
*
|
||||
* @example
|
||||
* // Using `new` constructor
|
||||
* $('#example').dataTable()
|
||||
*
|
||||
* new $.fn.dataTable.ColReorder( '#example', {
|
||||
* "iFixedColumnsRight": 1
|
||||
* } );
|
||||
*/
|
||||
iFixedColumnsRight: 0,
|
||||
|
||||
/**
|
||||
* Callback function that is fired when columns are reordered
|
||||
* Callback function that is fired when columns are reordered. The `column-
|
||||
* reorder` event is preferred over this callback
|
||||
* @type function():void
|
||||
* @default null
|
||||
* @static
|
||||
* @example
|
||||
* // Using the `oColReorder` option in the DataTables options object
|
||||
* $('#example').dataTable( {
|
||||
* "sDom": 'Rlfrtip',
|
||||
* "oColReorder": {
|
||||
* "fnReorderCallback": function () {
|
||||
* alert( 'Columns reordered' );
|
||||
* }
|
||||
* }
|
||||
* } );
|
||||
*
|
||||
* @example
|
||||
* // Using `new` constructor
|
||||
* $('#example').dataTable()
|
||||
*
|
||||
* new $.fn.dataTable.ColReorder( '#example', {
|
||||
* "fnReorderCallback": function () {
|
||||
* alert( 'Columns reordered' );
|
||||
* }
|
||||
* } );
|
||||
*/
|
||||
fnReorderCallback: null
|
||||
};
|
||||
@@ -1287,7 +1239,7 @@ ColReorder.defaults = {
|
||||
* @type String
|
||||
* @default As code
|
||||
*/
|
||||
ColReorder.version = "1.1.3";
|
||||
ColReorder.version = "1.3.1";
|
||||
|
||||
|
||||
|
||||
@@ -1303,7 +1255,7 @@ $.fn.DataTable.ColReorder = ColReorder;
|
||||
// Register a new feature with DataTables
|
||||
if ( typeof $.fn.dataTable == "function" &&
|
||||
typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
|
||||
$.fn.dataTableExt.fnVersionCheck('1.9.3') )
|
||||
$.fn.dataTableExt.fnVersionCheck('1.10.8') )
|
||||
{
|
||||
$.fn.dataTableExt.aoFeatures.push( {
|
||||
"fnInit": function( settings ) {
|
||||
@@ -1326,47 +1278,55 @@ if ( typeof $.fn.dataTable == "function" &&
|
||||
} );
|
||||
}
|
||||
else {
|
||||
alert( "Warning: ColReorder requires DataTables 1.9.3 or greater - www.datatables.net/download");
|
||||
alert( "Warning: ColReorder requires DataTables 1.10.8 or greater - www.datatables.net/download");
|
||||
}
|
||||
|
||||
|
||||
// Attach a listener to the document which listens for DataTables initialisation
|
||||
// events so we can automatically initialise
|
||||
$(document).on( 'preInit.dt.colReorder', function (e, settings) {
|
||||
if ( e.namespace !== 'dt' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var init = settings.oInit.colReorder;
|
||||
var defaults = DataTable.defaults.colReorder;
|
||||
|
||||
if ( init || defaults ) {
|
||||
var opts = $.extend( {}, init, defaults );
|
||||
|
||||
if ( init !== false ) {
|
||||
new ColReorder( settings, opts );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
// API augmentation
|
||||
if ( $.fn.dataTable.Api ) {
|
||||
$.fn.dataTable.Api.register( 'colReorder.reset()', function () {
|
||||
$.fn.dataTable.Api.register( 'colReorder.reset()', function () {
|
||||
return this.iterator( 'table', function ( ctx ) {
|
||||
ctx._colReorder.fnReset();
|
||||
} );
|
||||
} );
|
||||
|
||||
$.fn.dataTable.Api.register( 'colReorder.order()', function ( set, original ) {
|
||||
if ( set ) {
|
||||
return this.iterator( 'table', function ( ctx ) {
|
||||
ctx._colReorder.fnReset();
|
||||
ctx._colReorder.fnOrder( set, original );
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
$.fn.dataTable.Api.register( 'colReorder.order()', function ( set ) {
|
||||
if ( set ) {
|
||||
return this.iterator( 'table', function ( ctx ) {
|
||||
ctx._colReorder.fnOrder( set );
|
||||
} );
|
||||
}
|
||||
return this.context.length ?
|
||||
this.context[0]._colReorder.fnOrder() :
|
||||
null;
|
||||
} );
|
||||
|
||||
$.fn.dataTable.Api.register( 'colReorder.transpose()', function ( idx, dir ) {
|
||||
return this.context.length && this.context[0]._colReorder ?
|
||||
this.context[0]._colReorder.fnTranspose( idx, dir ) :
|
||||
idx;
|
||||
} );
|
||||
|
||||
return this.context.length ?
|
||||
this.context[0]._colReorder.fnOrder() :
|
||||
null;
|
||||
} );
|
||||
}
|
||||
|
||||
return ColReorder;
|
||||
}; // /factory
|
||||
|
||||
|
||||
// Define as an AMD module if possible
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
define( ['jquery', 'datatables'], factory );
|
||||
}
|
||||
else if ( typeof exports === 'object' ) {
|
||||
// Node/CommonJS
|
||||
factory( require('jquery'), require('datatables') );
|
||||
}
|
||||
else if ( jQuery && !jQuery.fn.dataTable.ColReorder ) {
|
||||
// Otherwise simply initialise as normal, stopping multiple evaluation
|
||||
factory( jQuery, jQuery.fn.dataTable );
|
||||
}
|
||||
|
||||
|
||||
})(window, document);
|
||||
}));
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
/*!
|
||||
ColReorder 1.1.3
|
||||
©2010-2014 SpryMedia Ltd - datatables.net/license
|
||||
ColReorder 1.3.1
|
||||
©2010-2015 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
(function(o,r,s){function p(d){for(var f=[],a=0,b=d.length;a<b;a++)f[d[a]]=a;return f}function l(d,f,a){f=d.splice(f,1)[0];d.splice(a,0,f)}function q(d,f,a){for(var b=[],e=0,h=d.childNodes.length;e<h;e++)1==d.childNodes[e].nodeType&&b.push(d.childNodes[e]);f=b[f];null!==a?d.insertBefore(f,b[a]):d.appendChild(f)}o=function(d){d.fn.dataTableExt.oApi.fnColReorder=function(a,b,e){var h=d.fn.dataTable.Api?!0:!1,c,g,f,m,n=a.aoColumns.length,i,j;i=function(a,b,c){if(a[b]){var e=a[b].split("."),d=e.shift();
|
||||
isNaN(1*d)||(a[b]=c[1*d]+"."+e.join("."))}};if(b!=e)if(0>b||b>=n)this.oApi._fnLog(a,1,"ColReorder 'from' index is out of bounds: "+b);else if(0>e||e>=n)this.oApi._fnLog(a,1,"ColReorder 'to' index is out of bounds: "+e);else{f=[];c=0;for(g=n;c<g;c++)f[c]=c;l(f,b,e);var k=p(f);c=0;for(g=a.aaSorting.length;c<g;c++)a.aaSorting[c][0]=k[a.aaSorting[c][0]];if(null!==a.aaSortingFixed){c=0;for(g=a.aaSortingFixed.length;c<g;c++)a.aaSortingFixed[c][0]=k[a.aaSortingFixed[c][0]]}c=0;for(g=n;c<g;c++){j=a.aoColumns[c];
|
||||
f=0;for(m=j.aDataSort.length;f<m;f++)j.aDataSort[f]=k[j.aDataSort[f]];h&&(j.idx=k[j.idx])}h&&d.each(a.aLastSort,function(b,c){a.aLastSort[b].src=k[c.src]});c=0;for(g=n;c<g;c++)j=a.aoColumns[c],"number"==typeof j.mData?(j.mData=k[j.mData],a.oApi._fnColumnOptions(a,c,{})):d.isPlainObject(j.mData)&&(i(j.mData,"_",k),i(j.mData,"filter",k),i(j.mData,"sort",k),i(j.mData,"type",k),a.oApi._fnColumnOptions(a,c,{}));if(a.aoColumns[b].bVisible){f=this.oApi._fnColumnIndexToVisible(a,b);m=null;for(c=e<b?e:e+1;null===
|
||||
m&&c<n;)m=this.oApi._fnColumnIndexToVisible(a,c),c++;i=a.nTHead.getElementsByTagName("tr");c=0;for(g=i.length;c<g;c++)q(i[c],f,m);if(null!==a.nTFoot){i=a.nTFoot.getElementsByTagName("tr");c=0;for(g=i.length;c<g;c++)q(i[c],f,m)}c=0;for(g=a.aoData.length;c<g;c++)null!==a.aoData[c].nTr&&q(a.aoData[c].nTr,f,m)}l(a.aoColumns,b,e);l(a.aoPreSearchCols,b,e);c=0;for(g=a.aoData.length;c<g;c++)i=a.aoData[c],h?(i.anCells&&l(i.anCells,b,e),"dom"!==i.src&&d.isArray(i._aData)&&l(i._aData,b,e)):(d.isArray(i._aData)&&
|
||||
l(i._aData,b,e),l(i._anHidden,b,e));c=0;for(g=a.aoHeader.length;c<g;c++)l(a.aoHeader[c],b,e);if(null!==a.aoFooter){c=0;for(g=a.aoFooter.length;c<g;c++)l(a.aoFooter[c],b,e)}h&&(new d.fn.dataTable.Api(a)).rows().invalidate();c=0;for(g=n;c<g;c++)d(a.aoColumns[c].nTh).off("click.DT"),this.oApi._fnSortAttachListener(a,a.aoColumns[c].nTh,c);d(a.oInstance).trigger("column-reorder",[a,{iFrom:b,iTo:e,aiInvertMapping:k}])}};var f=function(a,b){var e;d.fn.dataTable.Api?e=(new d.fn.dataTable.Api(a)).settings()[0]:
|
||||
a.fnSettings?e=a.fnSettings():"string"===typeof a?d.fn.dataTable.fnIsDataTable(d(a)[0])&&(e=d(a).eq(0).dataTable().fnSettings()):a.nodeName&&"table"===a.nodeName.toLowerCase()?d.fn.dataTable.fnIsDataTable(a.nodeName)&&(e=d(a.nodeName).dataTable().fnSettings()):a instanceof jQuery?d.fn.dataTable.fnIsDataTable(a[0])&&(e=a.eq(0).dataTable().fnSettings()):e=a;if(e._colReorder)throw"ColReorder already initialised on table #"+e.nTable.id;var h=d.fn.dataTable.camelToHungarian;h&&(h(f.defaults,f.defaults,
|
||||
!0),h(f.defaults,b||{}));this.s={dt:null,init:d.extend(!0,{},f.defaults,b),fixed:0,fixedRight:0,reorderCallback:null,mouse:{startX:-1,startY:-1,offsetX:-1,offsetY:-1,target:-1,targetIndex:-1,fromIndex:-1},aoTargets:[]};this.dom={drag:null,pointer:null};this.s.dt=e;this.s.dt._colReorder=this;this._fnConstruct();e.oApi._fnCallbackReg(e,"aoDestroyCallback",d.proxy(this._fnDestroy,this),"ColReorder");return this};f.prototype={fnReset:function(){for(var a=[],b=0,e=this.s.dt.aoColumns.length;b<e;b++)a.push(this.s.dt.aoColumns[b]._ColReorder_iOrigCol);
|
||||
this._fnOrderColumns(a);return this},fnGetCurrentOrder:function(){return this.fnOrder()},fnOrder:function(a){if(a===s){for(var a=[],b=0,e=this.s.dt.aoColumns.length;b<e;b++)a.push(this.s.dt.aoColumns[b]._ColReorder_iOrigCol);return a}this._fnOrderColumns(p(a));return this},_fnConstruct:function(){var a=this,b=this.s.dt.aoColumns.length,e;this.s.init.iFixedColumns&&(this.s.fixed=this.s.init.iFixedColumns);this.s.fixedRight=this.s.init.iFixedColumnsRight?this.s.init.iFixedColumnsRight:0;this.s.init.fnReorderCallback&&
|
||||
(this.s.reorderCallback=this.s.init.fnReorderCallback);for(e=0;e<b;e++)e>this.s.fixed-1&&e<b-this.s.fixedRight&&this._fnMouseListener(e,this.s.dt.aoColumns[e].nTh),this.s.dt.aoColumns[e]._ColReorder_iOrigCol=e;this.s.dt.oApi._fnCallbackReg(this.s.dt,"aoStateSaveParams",function(b,c){a._fnStateSave.call(a,c)},"ColReorder_State");var d=null;this.s.init.aiOrder&&(d=this.s.init.aiOrder.slice());this.s.dt.oLoadedState&&("undefined"!=typeof this.s.dt.oLoadedState.ColReorder&&this.s.dt.oLoadedState.ColReorder.length==
|
||||
this.s.dt.aoColumns.length)&&(d=this.s.dt.oLoadedState.ColReorder);if(d)if(a.s.dt._bInitComplete)b=p(d),a._fnOrderColumns.call(a,b);else{var c=!1;this.s.dt.aoDrawCallback.push({fn:function(){if(!a.s.dt._bInitComplete&&!c){c=true;var b=p(d);a._fnOrderColumns.call(a,b)}},sName:"ColReorder_Pre"})}else this._fnSetColumnIndexes()},_fnOrderColumns:function(a){if(a.length!=this.s.dt.aoColumns.length)this.s.dt.oInstance.oApi._fnLog(this.s.dt,1,"ColReorder - array reorder does not match known number of columns. Skipping.");
|
||||
else{for(var b=0,e=a.length;b<e;b++){var h=d.inArray(b,a);b!=h&&(l(a,h,b),this.s.dt.oInstance.fnColReorder(h,b))}(""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY)&&this.s.dt.oInstance.fnAdjustColumnSizing(!1);this.s.dt.oInstance.oApi._fnSaveState(this.s.dt);this._fnSetColumnIndexes();null!==this.s.reorderCallback&&this.s.reorderCallback.call(this)}},_fnStateSave:function(a){var b,e,h,c=this.s.dt.aoColumns;a.ColReorder=[];if(a.aaSorting){for(b=0;b<a.aaSorting.length;b++)a.aaSorting[b][0]=c[a.aaSorting[b][0]]._ColReorder_iOrigCol;
|
||||
var f=d.extend(!0,[],a.aoSearchCols);b=0;for(e=c.length;b<e;b++)h=c[b]._ColReorder_iOrigCol,a.aoSearchCols[h]=f[b],a.abVisCols[h]=c[b].bVisible,a.ColReorder.push(h)}else if(a.order){for(b=0;b<a.order.length;b++)a.order[b][0]=c[a.order[b][0]]._ColReorder_iOrigCol;f=d.extend(!0,[],a.columns);b=0;for(e=c.length;b<e;b++)h=c[b]._ColReorder_iOrigCol,a.columns[h]=f[b],a.ColReorder.push(h)}},_fnMouseListener:function(a,b){var e=this;d(b).on("mousedown.ColReorder",function(a){a.preventDefault();e._fnMouseDown.call(e,
|
||||
a,b)})},_fnMouseDown:function(a,b){var e=this,f=d(a.target).closest("th, td").offset(),c=parseInt(d(b).attr("data-column-index"),10);c!==s&&(this.s.mouse.startX=a.pageX,this.s.mouse.startY=a.pageY,this.s.mouse.offsetX=a.pageX-f.left,this.s.mouse.offsetY=a.pageY-f.top,this.s.mouse.target=this.s.dt.aoColumns[c].nTh,this.s.mouse.targetIndex=c,this.s.mouse.fromIndex=c,this._fnRegions(),d(r).on("mousemove.ColReorder",function(a){e._fnMouseMove.call(e,a)}).on("mouseup.ColReorder",function(a){e._fnMouseUp.call(e,
|
||||
a)}))},_fnMouseMove:function(a){if(null===this.dom.drag){if(5>Math.pow(Math.pow(a.pageX-this.s.mouse.startX,2)+Math.pow(a.pageY-this.s.mouse.startY,2),0.5))return;this._fnCreateDragNode()}this.dom.drag.css({left:a.pageX-this.s.mouse.offsetX,top:a.pageY-this.s.mouse.offsetY});for(var b=!1,e=this.s.mouse.toIndex,d=1,c=this.s.aoTargets.length;d<c;d++)if(a.pageX<this.s.aoTargets[d-1].x+(this.s.aoTargets[d].x-this.s.aoTargets[d-1].x)/2){this.dom.pointer.css("left",this.s.aoTargets[d-1].x);this.s.mouse.toIndex=
|
||||
this.s.aoTargets[d-1].to;b=!0;break}b||(this.dom.pointer.css("left",this.s.aoTargets[this.s.aoTargets.length-1].x),this.s.mouse.toIndex=this.s.aoTargets[this.s.aoTargets.length-1].to);this.s.init.bRealtime&&e!==this.s.mouse.toIndex&&(this.s.dt.oInstance.fnColReorder(this.s.mouse.fromIndex,this.s.mouse.toIndex),this.s.mouse.fromIndex=this.s.mouse.toIndex,this._fnRegions())},_fnMouseUp:function(){d(r).off("mousemove.ColReorder mouseup.ColReorder");null!==this.dom.drag&&(this.dom.drag.remove(),this.dom.pointer.remove(),
|
||||
this.dom.drag=null,this.dom.pointer=null,this.s.dt.oInstance.fnColReorder(this.s.mouse.fromIndex,this.s.mouse.toIndex),this._fnSetColumnIndexes(),(""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY)&&this.s.dt.oInstance.fnAdjustColumnSizing(!1),this.s.dt.oInstance.oApi._fnSaveState(this.s.dt),null!==this.s.reorderCallback&&this.s.reorderCallback.call(this))},_fnRegions:function(){var a=this.s.dt.aoColumns;this.s.aoTargets.splice(0,this.s.aoTargets.length);this.s.aoTargets.push({x:d(this.s.dt.nTable).offset().left,
|
||||
to:0});for(var b=0,e=0,f=a.length;e<f;e++)e!=this.s.mouse.fromIndex&&b++,a[e].bVisible&&this.s.aoTargets.push({x:d(a[e].nTh).offset().left+d(a[e].nTh).outerWidth(),to:b});0!==this.s.fixedRight&&this.s.aoTargets.splice(this.s.aoTargets.length-this.s.fixedRight);0!==this.s.fixed&&this.s.aoTargets.splice(0,this.s.fixed)},_fnCreateDragNode:function(){var a=""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY,b=this.s.dt.aoColumns[this.s.mouse.targetIndex].nTh,e=b.parentNode,f=e.parentNode,c=f.parentNode,
|
||||
g=d(b).clone();this.dom.drag=d(c.cloneNode(!1)).addClass("DTCR_clonedTable").append(d(f.cloneNode(!1)).append(d(e.cloneNode(!1)).append(g[0]))).css({position:"absolute",top:0,left:0,width:d(b).outerWidth(),height:d(b).outerHeight()}).appendTo("body");this.dom.pointer=d("<div></div>").addClass("DTCR_pointer").css({position:"absolute",top:a?d("div.dataTables_scroll",this.s.dt.nTableWrapper).offset().top:d(this.s.dt.nTable).offset().top,height:a?d("div.dataTables_scroll",this.s.dt.nTableWrapper).height():
|
||||
d(this.s.dt.nTable).height()}).appendTo("body")},_fnDestroy:function(){var a,b;a=0;for(b=this.s.dt.aoDrawCallback.length;a<b;a++)if("ColReorder_Pre"===this.s.dt.aoDrawCallback[a].sName){this.s.dt.aoDrawCallback.splice(a,1);break}d(this.s.dt.nTHead).find("*").off(".ColReorder");d.each(this.s.dt.aoColumns,function(a,b){d(b.nTh).removeAttr("data-column-index")});this.s=this.s.dt._colReorder=null},_fnSetColumnIndexes:function(){d.each(this.s.dt.aoColumns,function(a,b){d(b.nTh).attr("data-column-index",
|
||||
a)})}};f.defaults={aiOrder:null,bRealtime:!1,iFixedColumns:0,iFixedColumnsRight:0,fnReorderCallback:null};f.version="1.1.3";d.fn.dataTable.ColReorder=f;d.fn.DataTable.ColReorder=f;"function"==typeof d.fn.dataTable&&"function"==typeof d.fn.dataTableExt.fnVersionCheck&&d.fn.dataTableExt.fnVersionCheck("1.9.3")?d.fn.dataTableExt.aoFeatures.push({fnInit:function(a){var b=a.oInstance;a._colReorder?b.oApi._fnLog(a,1,"ColReorder attempted to initialise twice. Ignoring second"):(b=a.oInit,new f(a,b.colReorder||
|
||||
b.oColReorder||{}));return null},cFeature:"R",sFeature:"ColReorder"}):alert("Warning: ColReorder requires DataTables 1.9.3 or greater - www.datatables.net/download");d.fn.dataTable.Api&&(d.fn.dataTable.Api.register("colReorder.reset()",function(){return this.iterator("table",function(a){a._colReorder.fnReset()})}),d.fn.dataTable.Api.register("colReorder.order()",function(a){return a?this.iterator("table",function(b){b._colReorder.fnOrder(a)}):this.context.length?this.context[0]._colReorder.fnOrder():
|
||||
null}));return f};"function"===typeof define&&define.amd?define(["jquery","datatables"],o):"object"===typeof exports?o(require("jquery"),require("datatables")):jQuery&&!jQuery.fn.dataTable.ColReorder&&o(jQuery,jQuery.fn.dataTable)})(window,document);
|
||||
(function(f){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(n){return f(n,window,document)}):"object"===typeof exports?module.exports=function(n,k){n||(n=window);if(!k||!k.fn.dataTable)k=require("datatables.net")(n,k).$;return f(k,n,n.document)}:f(jQuery,window,document)})(function(f,n,k,r){function p(a){for(var c=[],d=0,e=a.length;d<e;d++)c[a[d]]=d;return c}function o(a,c,d){c=a.splice(c,1)[0];a.splice(d,0,c)}function q(a,c,d){for(var e=[],b=0,f=a.childNodes.length;b<
|
||||
f;b++)1==a.childNodes[b].nodeType&&e.push(a.childNodes[b]);c=e[c];null!==d?a.insertBefore(c,e[d]):a.appendChild(c)}var s=f.fn.dataTable;f.fn.dataTableExt.oApi.fnColReorder=function(a,c,d,e){var b,g,i,l,h,k=a.aoColumns.length,j;h=function(a,b,c){if(a[b]&&"function"!==typeof a[b]){var d=a[b].split("."),e=d.shift();isNaN(1*e)||(a[b]=c[1*e]+"."+d.join("."))}};if(c!=d)if(0>c||c>=k)this.oApi._fnLog(a,1,"ColReorder 'from' index is out of bounds: "+c);else if(0>d||d>=k)this.oApi._fnLog(a,1,"ColReorder 'to' index is out of bounds: "+
|
||||
d);else{i=[];b=0;for(g=k;b<g;b++)i[b]=b;o(i,c,d);var m=p(i);b=0;for(g=a.aaSorting.length;b<g;b++)a.aaSorting[b][0]=m[a.aaSorting[b][0]];if(null!==a.aaSortingFixed){b=0;for(g=a.aaSortingFixed.length;b<g;b++)a.aaSortingFixed[b][0]=m[a.aaSortingFixed[b][0]]}b=0;for(g=k;b<g;b++){j=a.aoColumns[b];i=0;for(l=j.aDataSort.length;i<l;i++)j.aDataSort[i]=m[j.aDataSort[i]];j.idx=m[j.idx]}f.each(a.aLastSort,function(b,c){a.aLastSort[b].src=m[c.src]});b=0;for(g=k;b<g;b++)j=a.aoColumns[b],"number"==typeof j.mData?
|
||||
j.mData=m[j.mData]:f.isPlainObject(j.mData)&&(h(j.mData,"_",m),h(j.mData,"filter",m),h(j.mData,"sort",m),h(j.mData,"type",m));if(a.aoColumns[c].bVisible){h=this.oApi._fnColumnIndexToVisible(a,c);l=null;for(b=d<c?d:d+1;null===l&&b<k;)l=this.oApi._fnColumnIndexToVisible(a,b),b++;i=a.nTHead.getElementsByTagName("tr");b=0;for(g=i.length;b<g;b++)q(i[b],h,l);if(null!==a.nTFoot){i=a.nTFoot.getElementsByTagName("tr");b=0;for(g=i.length;b<g;b++)q(i[b],h,l)}b=0;for(g=a.aoData.length;b<g;b++)null!==a.aoData[b].nTr&&
|
||||
q(a.aoData[b].nTr,h,l)}o(a.aoColumns,c,d);b=0;for(g=k;b<g;b++)a.oApi._fnColumnOptions(a,b,{});o(a.aoPreSearchCols,c,d);b=0;for(g=a.aoData.length;b<g;b++){l=a.aoData[b];if(j=l.anCells){o(j,c,d);i=0;for(h=j.length;i<h;i++)j[i]&&j[i]._DT_CellIndex&&(j[i]._DT_CellIndex.column=i)}"dom"!==l.src&&f.isArray(l._aData)&&o(l._aData,c,d)}b=0;for(g=a.aoHeader.length;b<g;b++)o(a.aoHeader[b],c,d);if(null!==a.aoFooter){b=0;for(g=a.aoFooter.length;b<g;b++)o(a.aoFooter[b],c,d)}(new f.fn.dataTable.Api(a)).rows().invalidate();
|
||||
b=0;for(g=k;b<g;b++)f(a.aoColumns[b].nTh).off("click.DT"),this.oApi._fnSortAttachListener(a,a.aoColumns[b].nTh,b);f(a.oInstance).trigger("column-reorder.dt",[a,{from:c,to:d,mapping:m,drop:e,iFrom:c,iTo:d,aiInvertMapping:m}])}};var h=function(a,c){var d=(new f.fn.dataTable.Api(a)).settings()[0];if(d._colReorder)return d._colReorder;!0===c&&(c={});var e=f.fn.dataTable.camelToHungarian;e&&(e(h.defaults,h.defaults,!0),e(h.defaults,c||{}));this.s={dt:null,init:f.extend(!0,{},h.defaults,c),fixed:0,fixedRight:0,
|
||||
reorderCallback:null,mouse:{startX:-1,startY:-1,offsetX:-1,offsetY:-1,target:-1,targetIndex:-1,fromIndex:-1},aoTargets:[]};this.dom={drag:null,pointer:null};this.s.dt=d;this.s.dt._colReorder=this;this._fnConstruct();return this};f.extend(h.prototype,{fnReset:function(){this._fnOrderColumns(this.fnOrder());return this},fnGetCurrentOrder:function(){return this.fnOrder()},fnOrder:function(a,c){var d=[],e,b,g=this.s.dt.aoColumns;if(a===r){e=0;for(b=g.length;e<b;e++)d.push(g[e]._ColReorder_iOrigCol);return d}if(c){g=
|
||||
this.fnOrder();e=0;for(b=a.length;e<b;e++)d.push(f.inArray(a[e],g));a=d}this._fnOrderColumns(p(a));return this},fnTranspose:function(a,c){c||(c="toCurrent");var d=this.fnOrder(),e=this.s.dt.aoColumns;return"toCurrent"===c?!f.isArray(a)?f.inArray(a,d):f.map(a,function(a){return f.inArray(a,d)}):!f.isArray(a)?e[a]._ColReorder_iOrigCol:f.map(a,function(a){return e[a]._ColReorder_iOrigCol})},_fnConstruct:function(){var a=this,c=this.s.dt.aoColumns.length,d=this.s.dt.nTable,e;this.s.init.iFixedColumns&&
|
||||
(this.s.fixed=this.s.init.iFixedColumns);this.s.init.iFixedColumnsLeft&&(this.s.fixed=this.s.init.iFixedColumnsLeft);this.s.fixedRight=this.s.init.iFixedColumnsRight?this.s.init.iFixedColumnsRight:0;this.s.init.fnReorderCallback&&(this.s.reorderCallback=this.s.init.fnReorderCallback);for(e=0;e<c;e++)e>this.s.fixed-1&&e<c-this.s.fixedRight&&this._fnMouseListener(e,this.s.dt.aoColumns[e].nTh),this.s.dt.aoColumns[e]._ColReorder_iOrigCol=e;this.s.dt.oApi._fnCallbackReg(this.s.dt,"aoStateSaveParams",function(b,
|
||||
c){a._fnStateSave.call(a,c)},"ColReorder_State");var b=null;this.s.init.aiOrder&&(b=this.s.init.aiOrder.slice());this.s.dt.oLoadedState&&("undefined"!=typeof this.s.dt.oLoadedState.ColReorder&&this.s.dt.oLoadedState.ColReorder.length==this.s.dt.aoColumns.length)&&(b=this.s.dt.oLoadedState.ColReorder);if(b)if(a.s.dt._bInitComplete)c=p(b),a._fnOrderColumns.call(a,c);else{var g=!1;f(d).on("draw.dt.colReorder",function(){if(!a.s.dt._bInitComplete&&!g){g=true;var c=p(b);a._fnOrderColumns.call(a,c)}})}else this._fnSetColumnIndexes();
|
||||
f(d).on("destroy.dt.colReorder",function(){f(d).off("destroy.dt.colReorder draw.dt.colReorder");f(a.s.dt.nTHead).find("*").off(".ColReorder");f.each(a.s.dt.aoColumns,function(a,b){f(b.nTh).removeAttr("data-column-index")});a.s.dt._colReorder=null;a.s=null})},_fnOrderColumns:function(a){var c=!1;if(a.length!=this.s.dt.aoColumns.length)this.s.dt.oInstance.oApi._fnLog(this.s.dt,1,"ColReorder - array reorder does not match known number of columns. Skipping.");else{for(var d=0,e=a.length;d<e;d++){var b=
|
||||
f.inArray(d,a);d!=b&&(o(a,b,d),this.s.dt.oInstance.fnColReorder(b,d,!0),c=!0)}this._fnSetColumnIndexes();c&&((""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY)&&this.s.dt.oInstance.fnAdjustColumnSizing(!1),this.s.dt.oInstance.oApi._fnSaveState(this.s.dt),null!==this.s.reorderCallback&&this.s.reorderCallback.call(this))}},_fnStateSave:function(a){var c,d,e,b=this.s.dt.aoColumns;a.ColReorder=[];if(a.aaSorting){for(c=0;c<a.aaSorting.length;c++)a.aaSorting[c][0]=b[a.aaSorting[c][0]]._ColReorder_iOrigCol;
|
||||
var g=f.extend(!0,[],a.aoSearchCols);c=0;for(d=b.length;c<d;c++)e=b[c]._ColReorder_iOrigCol,a.aoSearchCols[e]=g[c],a.abVisCols[e]=b[c].bVisible,a.ColReorder.push(e)}else if(a.order){for(c=0;c<a.order.length;c++)a.order[c][0]=b[a.order[c][0]]._ColReorder_iOrigCol;g=f.extend(!0,[],a.columns);c=0;for(d=b.length;c<d;c++)e=b[c]._ColReorder_iOrigCol,a.columns[e]=g[c],a.ColReorder.push(e)}},_fnMouseListener:function(a,c){var d=this;f(c).on("mousedown.ColReorder",function(a){a.preventDefault();d._fnMouseDown.call(d,
|
||||
a,c)})},_fnMouseDown:function(a,c){var d=this,e=f(a.target).closest("th, td").offset(),b=parseInt(f(c).attr("data-column-index"),10);b!==r&&(this.s.mouse.startX=a.pageX,this.s.mouse.startY=a.pageY,this.s.mouse.offsetX=a.pageX-e.left,this.s.mouse.offsetY=a.pageY-e.top,this.s.mouse.target=this.s.dt.aoColumns[b].nTh,this.s.mouse.targetIndex=b,this.s.mouse.fromIndex=b,this._fnRegions(),f(k).on("mousemove.ColReorder",function(a){d._fnMouseMove.call(d,a)}).on("mouseup.ColReorder",function(a){d._fnMouseUp.call(d,
|
||||
a)}))},_fnMouseMove:function(a){if(null===this.dom.drag){if(5>Math.pow(Math.pow(a.pageX-this.s.mouse.startX,2)+Math.pow(a.pageY-this.s.mouse.startY,2),0.5))return;this._fnCreateDragNode()}this.dom.drag.css({left:a.pageX-this.s.mouse.offsetX,top:a.pageY-this.s.mouse.offsetY});for(var c=!1,d=this.s.mouse.toIndex,e=1,b=this.s.aoTargets.length;e<b;e++)if(a.pageX<this.s.aoTargets[e-1].x+(this.s.aoTargets[e].x-this.s.aoTargets[e-1].x)/2){this.dom.pointer.css("left",this.s.aoTargets[e-1].x);this.s.mouse.toIndex=
|
||||
this.s.aoTargets[e-1].to;c=!0;break}c||(this.dom.pointer.css("left",this.s.aoTargets[this.s.aoTargets.length-1].x),this.s.mouse.toIndex=this.s.aoTargets[this.s.aoTargets.length-1].to);this.s.init.bRealtime&&d!==this.s.mouse.toIndex&&(this.s.dt.oInstance.fnColReorder(this.s.mouse.fromIndex,this.s.mouse.toIndex,!1),this.s.mouse.fromIndex=this.s.mouse.toIndex,this._fnRegions())},_fnMouseUp:function(){f(k).off("mousemove.ColReorder mouseup.ColReorder");null!==this.dom.drag&&(this.dom.drag.remove(),this.dom.pointer.remove(),
|
||||
this.dom.drag=null,this.dom.pointer=null,this.s.dt.oInstance.fnColReorder(this.s.mouse.fromIndex,this.s.mouse.toIndex,!0),this._fnSetColumnIndexes(),(""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY)&&this.s.dt.oInstance.fnAdjustColumnSizing(!1),this.s.dt.oInstance.oApi._fnSaveState(this.s.dt),null!==this.s.reorderCallback&&this.s.reorderCallback.call(this))},_fnRegions:function(){var a=this.s.dt.aoColumns;this.s.aoTargets.splice(0,this.s.aoTargets.length);this.s.aoTargets.push({x:f(this.s.dt.nTable).offset().left,
|
||||
to:0});for(var c=0,d=f(a[0].nTh).offset().left,e=0,b=a.length;e<b;e++)e!=this.s.mouse.fromIndex&&c++,a[e].bVisible&&"none"!==a[e].nTh.style.display&&(d+=f(a[e].nTh).outerWidth(),this.s.aoTargets.push({x:d,to:c}));0!==this.s.fixedRight&&this.s.aoTargets.splice(this.s.aoTargets.length-this.s.fixedRight);0!==this.s.fixed&&this.s.aoTargets.splice(0,this.s.fixed)},_fnCreateDragNode:function(){var a=""!==this.s.dt.oScroll.sX||""!==this.s.dt.oScroll.sY,c=this.s.dt.aoColumns[this.s.mouse.targetIndex].nTh,
|
||||
d=c.parentNode,e=d.parentNode,b=e.parentNode,g=f(c).clone();this.dom.drag=f(b.cloneNode(!1)).addClass("DTCR_clonedTable").append(f(e.cloneNode(!1)).append(f(d.cloneNode(!1)).append(g[0]))).css({position:"absolute",top:0,left:0,width:f(c).outerWidth(),height:f(c).outerHeight()}).appendTo("body");this.dom.pointer=f("<div></div>").addClass("DTCR_pointer").css({position:"absolute",top:a?f("div.dataTables_scroll",this.s.dt.nTableWrapper).offset().top:f(this.s.dt.nTable).offset().top,height:a?f("div.dataTables_scroll",
|
||||
this.s.dt.nTableWrapper).height():f(this.s.dt.nTable).height()}).appendTo("body")},_fnSetColumnIndexes:function(){f.each(this.s.dt.aoColumns,function(a,c){f(c.nTh).attr("data-column-index",a)})}});h.defaults={aiOrder:null,bRealtime:!0,iFixedColumnsLeft:0,iFixedColumnsRight:0,fnReorderCallback:null};h.version="1.3.1";f.fn.dataTable.ColReorder=h;f.fn.DataTable.ColReorder=h;"function"==typeof f.fn.dataTable&&"function"==typeof f.fn.dataTableExt.fnVersionCheck&&f.fn.dataTableExt.fnVersionCheck("1.10.8")?
|
||||
f.fn.dataTableExt.aoFeatures.push({fnInit:function(a){var c=a.oInstance;a._colReorder?c.oApi._fnLog(a,1,"ColReorder attempted to initialise twice. Ignoring second"):(c=a.oInit,new h(a,c.colReorder||c.oColReorder||{}));return null},cFeature:"R",sFeature:"ColReorder"}):alert("Warning: ColReorder requires DataTables 1.10.8 or greater - www.datatables.net/download");f(k).on("preInit.dt.colReorder",function(a,c){if("dt"===a.namespace){var d=c.oInit.colReorder,e=s.defaults.colReorder;if(d||e)e=f.extend({},
|
||||
d,e),!1!==d&&new h(c,e)}});f.fn.dataTable.Api.register("colReorder.reset()",function(){return this.iterator("table",function(a){a._colReorder.fnReset()})});f.fn.dataTable.Api.register("colReorder.order()",function(a,c){return a?this.iterator("table",function(d){d._colReorder.fnOrder(a,c)}):this.context.length?this.context[0]._colReorder.fnOrder():null});f.fn.dataTable.Api.register("colReorder.transpose()",function(a,c){return this.context.length&&this.context[0]._colReorder?this.context[0]._colReorder.fnTranspose(a,
|
||||
c):a});return h});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
MIT license
|
||||
|
||||
Copyright (c) 2010-2015 SpryMedia Limited
|
||||
http://datatables.net
|
||||
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
# FixedColumns
|
||||
|
||||
When making use of DataTables' x-axis scrolling feature (`scrollX`), you may wish to fix the left or right most columns in place. This plug-in for DataTables provides exactly this option (for non-scrolling tables, please use the FixedHeader plug-in, which can fix headers, footers and columns). Key features include:
|
||||
|
||||
* Freezes the left most column to the side of the table
|
||||
* Option to freeze two or more columns
|
||||
* Full integration with DataTables' scrolling options
|
||||
When making use of DataTables' x-axis scrolling feature (`scrollX`), you may wish to fix the left or right most columns in place. This extension for DataTables provides exactly this option (for non-scrolling tables, please use the FixedHeader extension, which can fix the header and footer).
|
||||
|
||||
|
||||
# Installation
|
||||
|
||||
To use FixedColumns, first download DataTables ( http://datatables.net/download ) and place the unzipped FixedColumns package into a `extensions` directory in the DataTables package. This will allow the pages in the examples to operate correctly. To see the examples running, open the `examples` directory in your web-browser.
|
||||
To use FixedColumns the primary way to obtain the software is to use the [DataTables downloader](//datatables.net/download). You can also include the individual files from the [DataTables CDN](//cdn.datatables.net). See the [documentation](http://datatables.net/extensions/fixedcolumns/) for full details.
|
||||
|
||||
## NPM and Bower
|
||||
|
||||
If you prefer to use a package manager such as NPM or Bower, distribution repositories are available with software built from this repository under the name `datatables.net-fixedcolumns`. Styling packages for Bootstrap, Foundation and other styling libraries are also available by adding a suffix to the package name.
|
||||
|
||||
Please see the DataTables [NPM](//datatables.net/download/npm) and [Bower](//datatables.net/download/bower) installation pages for further information. The [DataTables installation manual](//datatables.net/manual/installation) also has details on how to use package managers with DataTables.
|
||||
|
||||
|
||||
# Basic usage
|
||||
|
||||
FixedColumns is initialised using the `$.fn.dataTable.FixedColumns()` constructor. For example:
|
||||
FixedColumns is initialised using the `fixedColumns` option in the DataTables constructor - a simple boolean `true` will enable the feature. Further options can be specified using this option as an object - see the documentation for details. DataTables' scrolling options should also be enabled to use this feature.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
$(document).ready(function() {
|
||||
@@ -22,21 +26,19 @@ $(document).ready(function() {
|
||||
scrollY: "300px",
|
||||
scrollX: true,
|
||||
scrollCollapse: true,
|
||||
paging: false
|
||||
paging: false,
|
||||
fixedColumns: true
|
||||
} );
|
||||
|
||||
new $.fn.dataTable.FixedColumns( table );
|
||||
} );
|
||||
```
|
||||
|
||||
|
||||
# Documentation / support
|
||||
|
||||
* Documentation: http://datatables.net/extensions/FixedColumns/
|
||||
* DataTables support forums: http://datatables.net/forums
|
||||
* [Documentation](https://datatables.net/extensions/fixedcolumns/)
|
||||
* [DataTables support forums](http://datatables.net/forums)
|
||||
|
||||
|
||||
# GitHub
|
||||
|
||||
If you fancy getting involved with the development of FixedColumns and help make it better, please refer to its GitHub repo: https://github.com/DataTables/FixedColumns
|
||||
|
||||
If you fancy getting involved with the development of FixedColumns and help make it better, please refer to its [GitHub repo](https://github.com/DataTables/FixedColumns).
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*! FixedColumns 3.0.4
|
||||
* ©2010-2014 SpryMedia Ltd - datatables.net/license
|
||||
/*! FixedColumns 3.2.1
|
||||
* ©2010-2016 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @summary FixedColumns
|
||||
* @description Freeze columns in place on a scrolling DataTable
|
||||
* @version 3.0.4
|
||||
* @version 3.2.1
|
||||
* @file dataTables.fixedColumns.js
|
||||
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
||||
* @contact www.sprymedia.co.uk/contact
|
||||
* @copyright Copyright 2010-2014 SpryMedia Ltd.
|
||||
* @copyright Copyright 2010-2016 SpryMedia Ltd.
|
||||
*
|
||||
* This source file is free software, available under the following license:
|
||||
* MIT license - http://datatables.net/license/mit
|
||||
@@ -20,13 +20,35 @@
|
||||
*
|
||||
* For details please refer to: http://www.datatables.net
|
||||
*/
|
||||
(function( factory ){
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( ['jquery', 'datatables.net'], function ( $ ) {
|
||||
return factory( $, window, document );
|
||||
} );
|
||||
}
|
||||
else if ( typeof exports === 'object' ) {
|
||||
// CommonJS
|
||||
module.exports = function (root, $) {
|
||||
if ( ! root ) {
|
||||
root = window;
|
||||
}
|
||||
|
||||
if ( ! $ || ! $.fn.dataTable ) {
|
||||
$ = require('datatables.net')(root, $).$;
|
||||
}
|
||||
|
||||
(function(window, document, undefined) {
|
||||
|
||||
|
||||
var factory = function( $, DataTable ) {
|
||||
"use strict";
|
||||
return factory( $, root, root.document );
|
||||
};
|
||||
}
|
||||
else {
|
||||
// Browser
|
||||
factory( jQuery, window, document );
|
||||
}
|
||||
}(function( $, window, document, undefined ) {
|
||||
'use strict';
|
||||
var DataTable = $.fn.dataTable;
|
||||
var _firefoxScroll;
|
||||
|
||||
/**
|
||||
* When making use of DataTables' x-axis scrolling feature, you may wish to
|
||||
@@ -62,14 +84,12 @@ var FixedColumns = function ( dt, init ) {
|
||||
var that = this;
|
||||
|
||||
/* Sanity check - you just know it will happen */
|
||||
if ( ! ( this instanceof FixedColumns ) )
|
||||
{
|
||||
if ( ! ( this instanceof FixedColumns ) ) {
|
||||
alert( "FixedColumns warning: FixedColumns must be initialised with the 'new' keyword." );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( typeof init == 'undefined' )
|
||||
{
|
||||
if ( init === undefined || init === true ) {
|
||||
init = {};
|
||||
}
|
||||
|
||||
@@ -82,9 +102,7 @@ var FixedColumns = function ( dt, init ) {
|
||||
}
|
||||
|
||||
// v1.10 allows the settings object to be got form a number of sources
|
||||
var dtSettings = $.fn.dataTable.Api ?
|
||||
new $.fn.dataTable.Api( dt ).settings()[0] :
|
||||
dt.fnSettings();
|
||||
var dtSettings = new $.fn.dataTable.Api( dt ).settings()[0];
|
||||
|
||||
/**
|
||||
* Settings object which contains customisable information for FixedColumns instance
|
||||
@@ -265,6 +283,10 @@ var FixedColumns = function ( dt, init ) {
|
||||
}
|
||||
};
|
||||
|
||||
if ( dtSettings._oFixedColumns ) {
|
||||
throw 'FixedColumns already initialised on this table';
|
||||
}
|
||||
|
||||
/* Attach the instance to the DataTables instance so it can be accessed easily */
|
||||
dtSettings._oFixedColumns = this;
|
||||
|
||||
@@ -283,7 +305,7 @@ var FixedColumns = function ( dt, init ) {
|
||||
|
||||
|
||||
|
||||
FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
$.extend( FixedColumns.prototype , {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
@@ -468,13 +490,30 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
|
||||
/* Event handlers */
|
||||
var mouseController;
|
||||
var mouseDown = false;
|
||||
|
||||
// When the mouse is down (drag scroll) the mouse controller cannot
|
||||
// change, as the browser keeps the original element as the scrolling one
|
||||
$(this.s.dt.nTableWrapper).on( 'mousedown.DTFC', function () {
|
||||
mouseDown = true;
|
||||
|
||||
$(document).one( 'mouseup', function () {
|
||||
mouseDown = false;
|
||||
} );
|
||||
} );
|
||||
|
||||
// When the body is scrolled - scroll the left and right columns
|
||||
$(this.dom.scroller)
|
||||
.on( 'mouseover.DTFC touchstart.DTFC', function () {
|
||||
mouseController = 'main';
|
||||
if ( ! mouseDown ) {
|
||||
mouseController = 'main';
|
||||
}
|
||||
} )
|
||||
.on( 'scroll.DTFC', function () {
|
||||
.on( 'scroll.DTFC', function (e) {
|
||||
if ( ! mouseController && e.originalEvent ) {
|
||||
mouseController = 'main';
|
||||
}
|
||||
|
||||
if ( mouseController === 'main' ) {
|
||||
if ( that.s.iLeftColumns > 0 ) {
|
||||
that.dom.grid.left.liner.scrollTop = that.dom.scroller.scrollTop;
|
||||
@@ -493,9 +532,15 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
// When scrolling the left column, scroll the body and right column
|
||||
$(that.dom.grid.left.liner)
|
||||
.on( 'mouseover.DTFC touchstart.DTFC', function () {
|
||||
mouseController = 'left';
|
||||
if ( ! mouseDown ) {
|
||||
mouseController = 'left';
|
||||
}
|
||||
} )
|
||||
.on( 'scroll.DTFC', function () {
|
||||
.on( 'scroll.DTFC', function ( e ) {
|
||||
if ( ! mouseController && e.originalEvent ) {
|
||||
mouseController = 'left';
|
||||
}
|
||||
|
||||
if ( mouseController === 'left' ) {
|
||||
that.dom.scroller.scrollTop = that.dom.grid.left.liner.scrollTop;
|
||||
if ( that.s.iRightColumns > 0 ) {
|
||||
@@ -503,7 +548,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
}
|
||||
}
|
||||
} )
|
||||
.on( wheelType, function(e) { // xxx update the destroy as well
|
||||
.on( wheelType, function(e) {
|
||||
// Pass horizontal scrolling through
|
||||
var xDelta = e.type === 'wheel' ?
|
||||
-e.originalEvent.deltaX :
|
||||
@@ -516,9 +561,15 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
// When scrolling the right column, scroll the body and the left column
|
||||
$(that.dom.grid.right.liner)
|
||||
.on( 'mouseover.DTFC touchstart.DTFC', function () {
|
||||
mouseController = 'right';
|
||||
if ( ! mouseDown ) {
|
||||
mouseController = 'right';
|
||||
}
|
||||
} )
|
||||
.on( 'scroll.DTFC', function () {
|
||||
.on( 'scroll.DTFC', function ( e ) {
|
||||
if ( ! mouseController && e.originalEvent ) {
|
||||
mouseController = 'right';
|
||||
}
|
||||
|
||||
if ( mouseController === 'right' ) {
|
||||
that.dom.scroller.scrollTop = that.dom.grid.right.liner.scrollTop;
|
||||
if ( that.s.iLeftColumns > 0 ) {
|
||||
@@ -544,6 +595,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
|
||||
jqTable
|
||||
.on( 'draw.dt.DTFC', function () {
|
||||
that._fnColCalc();
|
||||
that._fnDraw.call( that, bFirstDraw );
|
||||
bFirstDraw = false;
|
||||
} )
|
||||
@@ -551,21 +603,27 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
that._fnColCalc();
|
||||
that._fnGridLayout( that );
|
||||
} )
|
||||
.on( 'column-visibility.dt.DTFC', function () {
|
||||
that._fnColCalc();
|
||||
that._fnGridLayout( that );
|
||||
that._fnDraw( true );
|
||||
.on( 'column-visibility.dt.DTFC', function ( e, settings, column, vis, recalc ) {
|
||||
if ( recalc === undefined || recalc ) {
|
||||
that._fnColCalc();
|
||||
that._fnGridLayout( that );
|
||||
that._fnDraw( true );
|
||||
}
|
||||
} )
|
||||
.on( 'select.dt.DTFC deselect.dt.DTFC', function ( e, dt, type, indexes ) {
|
||||
that._fnDraw( false );
|
||||
} )
|
||||
.on( 'destroy.dt.DTFC', function () {
|
||||
jqTable.off( 'column-sizing.dt.DTFC destroy.dt.DTFC draw.dt.DTFC' );
|
||||
jqTable.off( '.DTFC' );
|
||||
|
||||
$(that.dom.scroller).off( 'scroll.DTFC mouseover.DTFC' );
|
||||
$(window).off( 'resize.DTFC' );
|
||||
$(that.dom.scroller).off( '.DTFC' );
|
||||
$(window).off( '.DTFC' );
|
||||
$(this.s.dt.nTableWrapper).off( '.DTFC' );
|
||||
|
||||
$(that.dom.grid.left.liner).off( 'scroll.DTFC mouseover.DTFC '+wheelType );
|
||||
$(that.dom.grid.left.liner).off( '.DTFC '+wheelType );
|
||||
$(that.dom.grid.left.wrapper).remove();
|
||||
|
||||
$(that.dom.grid.right.liner).off( 'scroll.DTFC mouseover.DTFC '+wheelType );
|
||||
$(that.dom.grid.right.liner).off( '.DTFC '+wheelType );
|
||||
$(that.dom.grid.right.wrapper).remove();
|
||||
} );
|
||||
|
||||
@@ -667,7 +725,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
'</div>'+
|
||||
'<div class="DTFC_LeftFootWrapper" style="position:relative; top:0; left:0; overflow:hidden;"></div>'+
|
||||
'</div>'+
|
||||
'<div class="DTFC_RightWrapper" style="position:absolute; top:0; left:0;">'+
|
||||
'<div class="DTFC_RightWrapper" style="position:absolute; top:0; right:0;">'+
|
||||
'<div class="DTFC_RightHeadWrapper" style="position:relative; top:0; left:0;">'+
|
||||
'<div class="DTFC_RightHeadBlocker DTFC_Blocker" style="position:absolute; top:0; bottom:0;"></div>'+
|
||||
'</div>'+
|
||||
@@ -704,6 +762,8 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
this.dom.grid.right.body = nRight.childNodes[1];
|
||||
this.dom.grid.right.liner = $('div.DTFC_RightBodyLiner', nSWrapper)[0];
|
||||
|
||||
nRight.style.right = oOverflow.bar+"px";
|
||||
|
||||
block = $('div.DTFC_RightHeadBlocker', nSWrapper)[0];
|
||||
block.style.width = oOverflow.bar+"px";
|
||||
block.style.right = -oOverflow.bar+"px";
|
||||
@@ -729,6 +789,24 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
this.dom.grid.right.foot = nRight.childNodes[2];
|
||||
}
|
||||
}
|
||||
|
||||
// RTL support - swap the position of the left and right columns (#48)
|
||||
if ( $(this.dom.body).css('direction') === 'rtl' ) {
|
||||
$(nLeft).css( {
|
||||
left: '',
|
||||
right: 0
|
||||
} );
|
||||
|
||||
$(nRight).css( {
|
||||
left: oOverflow.bar+"px",
|
||||
right: ''
|
||||
} );
|
||||
|
||||
$('div.DTFC_RightHeadBlocker', nSWrapper).css( {
|
||||
left: -oOverflow.bar+'px',
|
||||
right: ''
|
||||
} );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -739,6 +817,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
*/
|
||||
"_fnGridLayout": function ()
|
||||
{
|
||||
var that = this;
|
||||
var oGrid = this.dom.grid;
|
||||
var iWidth = $(oGrid.wrapper).width();
|
||||
var iBodyHeight = $(this.s.dt.nTable.parentNode).outerHeight();
|
||||
@@ -755,6 +834,12 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
node.style.paddingRight = "20px";
|
||||
node.style.boxSizing = "border-box";
|
||||
}
|
||||
else if ( that._firefoxScrollError() ) {
|
||||
// See the above function for why this is required
|
||||
if ( $(node).height() > 34 ) {
|
||||
node.style.width = (width+oOverflow.bar)+"px";
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Otherwise just overflow by the scrollbar
|
||||
node.style.width = (width+oOverflow.bar)+"px";
|
||||
@@ -791,7 +876,6 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
}
|
||||
|
||||
oGrid.right.wrapper.style.width = iRightWidth+"px";
|
||||
oGrid.right.wrapper.style.left = iRight+"px";
|
||||
oGrid.right.wrapper.style.height = "1px";
|
||||
oGrid.right.body.style.height = iBodyHeight+"px";
|
||||
if ( oGrid.right.foot ) {
|
||||
@@ -922,9 +1006,10 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
* @returns {Array} Copy of the layout array
|
||||
* @param {Object} aoOriginal Layout array from DataTables (aoHeader or aoFooter)
|
||||
* @param {Object} aiColumns Columns to copy
|
||||
* @param {boolean} events Copy cell events or not
|
||||
* @private
|
||||
*/
|
||||
"_fnCopyLayout": function ( aoOriginal, aiColumns )
|
||||
"_fnCopyLayout": function ( aoOriginal, aiColumns, events )
|
||||
{
|
||||
var aReturn = [];
|
||||
var aClones = [];
|
||||
@@ -933,7 +1018,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
for ( var i=0, iLen=aoOriginal.length ; i<iLen ; i++ )
|
||||
{
|
||||
var aRow = [];
|
||||
aRow.nTr = $(aoOriginal[i].nTr).clone(true, true)[0];
|
||||
aRow.nTr = $(aoOriginal[i].nTr).clone(events, false)[0];
|
||||
|
||||
for ( var j=0, jLen=this.s.iTableColumns ; j<jLen ; j++ )
|
||||
{
|
||||
@@ -945,7 +1030,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
var iCloned = $.inArray( aoOriginal[i][j].cell, aCloned );
|
||||
if ( iCloned === -1 )
|
||||
{
|
||||
var nClone = $(aoOriginal[i][j].cell).clone(true, true)[0];
|
||||
var nClone = $(aoOriginal[i][j].cell).clone(events, false)[0];
|
||||
aClones.push( nClone );
|
||||
aCloned.push( aoOriginal[i][j].cell );
|
||||
|
||||
@@ -992,17 +1077,15 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
*/
|
||||
if ( bAll )
|
||||
{
|
||||
if ( oClone.header !== null )
|
||||
{
|
||||
oClone.header.parentNode.removeChild( oClone.header );
|
||||
}
|
||||
oClone.header = $(this.dom.header).clone(true, true)[0];
|
||||
$(oClone.header).remove();
|
||||
|
||||
oClone.header = $(this.dom.header).clone(true, false)[0];
|
||||
oClone.header.className += " DTFC_Cloned";
|
||||
oClone.header.style.width = "100%";
|
||||
oGrid.head.appendChild( oClone.header );
|
||||
|
||||
/* Copy the DataTables layout cache for the header for our floating column */
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoHeader, aiColumns );
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoHeader, aiColumns, true );
|
||||
jqCloneThead = $('>thead', oClone.header);
|
||||
jqCloneThead.empty();
|
||||
|
||||
@@ -1024,7 +1107,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
* cloned cells, just copy the classes across. To get the matching layout for the
|
||||
* fixed component, we use the DataTables _fnDetectHeader method, allowing 1:1 mapping
|
||||
*/
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoHeader, aiColumns );
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoHeader, aiColumns, false );
|
||||
aoFixedHeader=[];
|
||||
|
||||
dt.oApi._fnDetectHeader( aoFixedHeader, $('>thead', oClone.header)[0] );
|
||||
@@ -1055,7 +1138,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
|
||||
if ( oClone.body !== null )
|
||||
{
|
||||
oClone.body.parentNode.removeChild( oClone.body );
|
||||
$(oClone.body).remove();
|
||||
oClone.body = null;
|
||||
}
|
||||
|
||||
@@ -1100,12 +1183,14 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
|
||||
/* Add in the tbody elements, cloning form the master table */
|
||||
$('>tbody>tr', that.dom.body).each( function (z) {
|
||||
var n = this.cloneNode(false);
|
||||
n.removeAttribute('id');
|
||||
var i = that.s.dt.oFeatures.bServerSide===false ?
|
||||
that.s.dt.aiDisplay[ that.s.dt._iDisplayStart+z ] : z;
|
||||
var aTds = that.s.dt.aoData[ i ].anCells || $(this).children('td, th');
|
||||
|
||||
var n = this.cloneNode(false);
|
||||
n.removeAttribute('id');
|
||||
n.setAttribute( 'data-dt-row', i );
|
||||
|
||||
for ( iIndex=0 ; iIndex<aiColumns.length ; iIndex++ )
|
||||
{
|
||||
iColumn = aiColumns[iIndex];
|
||||
@@ -1113,6 +1198,8 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
if ( aTds.length > 0 )
|
||||
{
|
||||
nClone = $( aTds[iColumn] ).clone(true, true)[0];
|
||||
nClone.setAttribute( 'data-dt-row', i );
|
||||
nClone.setAttribute( 'data-dt-column', iIndex );
|
||||
n.appendChild( nClone );
|
||||
}
|
||||
}
|
||||
@@ -1169,7 +1256,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
oGrid.foot.appendChild( oClone.footer );
|
||||
|
||||
/* Copy the footer just like we do for the header */
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoFooter, aiColumns );
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoFooter, aiColumns, true );
|
||||
var jqCloneTfoot = $('>tfoot', oClone.footer);
|
||||
jqCloneTfoot.empty();
|
||||
|
||||
@@ -1181,7 +1268,7 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
}
|
||||
else
|
||||
{
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoFooter, aiColumns );
|
||||
aoCloneLayout = this._fnCopyLayout( dt.aoFooter, aiColumns, false );
|
||||
var aoCurrFooter=[];
|
||||
|
||||
dt.oApi._fnDetectHeader( aoCurrFooter, $('>tfoot', oClone.footer)[0] );
|
||||
@@ -1279,8 +1366,43 @@ FixedColumns.prototype = /** @lends FixedColumns.prototype */{
|
||||
anClone[i].style.height = heights[i]+"px";
|
||||
anOriginal[i].style.height = heights[i]+"px";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine if the UA suffers from Firefox's overflow:scroll scrollbars
|
||||
* not being shown bug.
|
||||
*
|
||||
* Firefox doesn't draw scrollbars, even if it is told to using
|
||||
* overflow:scroll, if the div is less than 34px height. See bugs 292284 and
|
||||
* 781885. Using UA detection here since this is particularly hard to detect
|
||||
* using objects - its a straight up rendering error in Firefox.
|
||||
*
|
||||
* @return {boolean} True if Firefox error is present, false otherwise
|
||||
*/
|
||||
_firefoxScrollError: function () {
|
||||
if ( _firefoxScroll === undefined ) {
|
||||
var test = $('<div/>')
|
||||
.css( {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
height: 10,
|
||||
width: 50,
|
||||
overflow: 'scroll'
|
||||
} )
|
||||
.appendTo( 'body' );
|
||||
|
||||
// Make sure this doesn't apply on Macs with 0 width scrollbars
|
||||
_firefoxScroll = (
|
||||
test[0].clientWidth === test[0].offsetWidth && this._fnDTOverflow().bar !== 0
|
||||
);
|
||||
|
||||
test.remove();
|
||||
}
|
||||
|
||||
return _firefoxScroll;
|
||||
}
|
||||
};
|
||||
} );
|
||||
|
||||
|
||||
|
||||
@@ -1376,48 +1498,108 @@ FixedColumns.defaults = /** @lends FixedColumns.defaults */{
|
||||
* @default See code
|
||||
* @static
|
||||
*/
|
||||
FixedColumns.version = "3.0.4";
|
||||
FixedColumns.version = "3.2.1";
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Fired events (for documentation)
|
||||
* DataTables API integration
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
DataTable.Api.register( 'fixedColumns()', function () {
|
||||
return this;
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'fixedColumns().update()', function () {
|
||||
return this.iterator( 'table', function ( ctx ) {
|
||||
if ( ctx._oFixedColumns ) {
|
||||
ctx._oFixedColumns.fnUpdate();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'fixedColumns().relayout()', function () {
|
||||
return this.iterator( 'table', function ( ctx ) {
|
||||
if ( ctx._oFixedColumns ) {
|
||||
ctx._oFixedColumns.fnRedrawLayout();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'rows().recalcHeight()', function () {
|
||||
return this.iterator( 'row', function ( ctx, idx ) {
|
||||
if ( ctx._oFixedColumns ) {
|
||||
ctx._oFixedColumns.fnRecalculateHeight( this.row(idx).node() );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'fixedColumns().rowIndex()', function ( row ) {
|
||||
row = $(row);
|
||||
|
||||
return row.parents('.DTFC_Cloned').length ?
|
||||
this.rows( { page: 'current' } ).indexes()[ row.index() ] :
|
||||
this.row( row ).index();
|
||||
} );
|
||||
|
||||
DataTable.Api.register( 'fixedColumns().cellIndex()', function ( cell ) {
|
||||
cell = $(cell);
|
||||
|
||||
if ( cell.parents('.DTFC_Cloned').length ) {
|
||||
var rowClonedIdx = cell.parent().index();
|
||||
var rowIdx = this.rows( { page: 'current' } ).indexes()[ rowClonedIdx ];
|
||||
var columnIdx;
|
||||
|
||||
if ( cell.parents('.DTFC_LeftWrapper').length ) {
|
||||
columnIdx = cell.index();
|
||||
}
|
||||
else {
|
||||
var columns = this.columns().flatten().length;
|
||||
columnIdx = columns - this.context[0]._oFixedColumns.s.iRightColumns + cell.index();
|
||||
}
|
||||
|
||||
return {
|
||||
row: rowIdx,
|
||||
column: this.column.index( 'toData', columnIdx ),
|
||||
columnVisible: columnIdx
|
||||
};
|
||||
}
|
||||
else {
|
||||
return this.cell( cell ).index();
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Initialisation
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
// Attach a listener to the document which listens for DataTables initialisation
|
||||
// events so we can automatically initialise
|
||||
$(document).on( 'init.dt.fixedColumns', function (e, settings) {
|
||||
if ( e.namespace !== 'dt' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var init = settings.oInit.fixedColumns;
|
||||
var defaults = DataTable.defaults.fixedColumns;
|
||||
|
||||
if ( init || defaults ) {
|
||||
var opts = $.extend( {}, init, defaults );
|
||||
|
||||
if ( init !== false ) {
|
||||
new FixedColumns( settings, opts );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
* Event fired whenever FixedColumns redraws the fixed columns (i.e. clones the table elements from the main DataTable). This will occur whenever the DataTable that the FixedColumns instance is attached does its own draw.
|
||||
* @name FixedColumns#draw.dtfc
|
||||
* @event
|
||||
* @param {event} e jQuery event object
|
||||
* @param {object} o Event parameters from FixedColumns
|
||||
* @param {object} o.leftClone Instance's object dom.clone.left for easy reference. This object contains references to the left fixed clumn column's nodes
|
||||
* @param {object} o.rightClone Instance's object dom.clone.right for easy reference. This object contains references to the right fixed clumn column's nodes
|
||||
*/
|
||||
|
||||
|
||||
// Make FixedColumns accessible from the DataTables instance
|
||||
$.fn.dataTable.FixedColumns = FixedColumns;
|
||||
$.fn.DataTable.FixedColumns = FixedColumns;
|
||||
|
||||
|
||||
return FixedColumns;
|
||||
}; // /factory
|
||||
|
||||
|
||||
// Define as an AMD module if possible
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
define( ['jquery', 'datatables'], factory );
|
||||
}
|
||||
else if ( typeof exports === 'object' ) {
|
||||
// Node/CommonJS
|
||||
factory( require('jquery'), require('datatables') );
|
||||
}
|
||||
else if ( jQuery && !jQuery.fn.dataTable.FixedColumns ) {
|
||||
// Otherwise simply initialise as normal, stopping multiple evaluation
|
||||
factory( jQuery, jQuery.fn.dataTable );
|
||||
}
|
||||
|
||||
|
||||
})(window, document);
|
||||
|
||||
}));
|
||||
@@ -1,30 +1,35 @@
|
||||
/*!
|
||||
FixedColumns 3.0.4
|
||||
©2010-2014 SpryMedia Ltd - datatables.net/license
|
||||
FixedColumns 3.2.1
|
||||
©2010-2016 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
(function(r,s,t){var p=function(d){var j=function(a,b){var c=this;if(this instanceof j){"undefined"==typeof b&&(b={});var g=d.fn.dataTable.camelToHungarian;g&&(g(j.defaults,j.defaults,!0),g(j.defaults,b));g=d.fn.dataTable.Api?(new d.fn.dataTable.Api(a)).settings()[0]:a.fnSettings();this.s={dt:g,iTableColumns:g.aoColumns.length,aiOuterWidths:[],aiInnerWidths:[]};this.dom={scroller:null,header:null,body:null,footer:null,grid:{wrapper:null,dt:null,left:{wrapper:null,head:null,body:null,foot:null},right:{wrapper:null,
|
||||
head:null,body:null,foot:null}},clone:{left:{header:null,body:null,footer:null},right:{header:null,body:null,footer:null}}};g._oFixedColumns=this;g._bInitComplete?this._fnConstruct(b):g.oApi._fnCallbackReg(g,"aoInitComplete",function(){c._fnConstruct(b)},"FixedColumns")}else alert("FixedColumns warning: FixedColumns must be initialised with the 'new' keyword.")};j.prototype={fnUpdate:function(){this._fnDraw(!0)},fnRedrawLayout:function(){this._fnColCalc();this._fnGridLayout();this.fnUpdate()},fnRecalculateHeight:function(a){delete a._DTTC_iHeight;
|
||||
a.style.height="auto"},fnSetRowHeight:function(a,b){a.style.height=b+"px"},fnGetPosition:function(a){var b=this.s.dt.oInstance;if(d(a).parents(".DTFC_Cloned").length){if("tr"===a.nodeName.toLowerCase())return a=d(a).index(),b.fnGetPosition(d("tr",this.s.dt.nTBody)[a]);var c=d(a).index(),a=d(a.parentNode).index();return[b.fnGetPosition(d("tr",this.s.dt.nTBody)[a]),c,b.oApi._fnVisibleToColumnIndex(this.s.dt,c)]}return b.fnGetPosition(a)},_fnConstruct:function(a){var b=this;if("function"!=typeof this.s.dt.oInstance.fnVersionCheck||
|
||||
!0!==this.s.dt.oInstance.fnVersionCheck("1.8.0"))alert("FixedColumns "+j.VERSION+" required DataTables 1.8.0 or later. Please upgrade your DataTables installation");else if(""===this.s.dt.oScroll.sX)this.s.dt.oInstance.oApi._fnLog(this.s.dt,1,"FixedColumns is not needed (no x-scrolling in DataTables enabled), so no action will be taken. Use 'FixedHeader' for column fixing when scrolling is not enabled");else{this.s=d.extend(!0,this.s,j.defaults,a);a=this.s.dt.oClasses;this.dom.grid.dt=d(this.s.dt.nTable).parents("div."+
|
||||
a.sScrollWrapper)[0];this.dom.scroller=d("div."+a.sScrollBody,this.dom.grid.dt)[0];this._fnColCalc();this._fnGridSetup();var c;d(this.dom.scroller).on("mouseover.DTFC touchstart.DTFC",function(){c="main"}).on("scroll.DTFC",function(){if("main"===c&&(0<b.s.iLeftColumns&&(b.dom.grid.left.liner.scrollTop=b.dom.scroller.scrollTop),0<b.s.iRightColumns))b.dom.grid.right.liner.scrollTop=b.dom.scroller.scrollTop});var g="onwheel"in s.createElement("div")?"wheel.DTFC":"mousewheel.DTFC";if(0<b.s.iLeftColumns)d(b.dom.grid.left.liner).on("mouseover.DTFC touchstart.DTFC",
|
||||
function(){c="left"}).on("scroll.DTFC",function(){"left"===c&&(b.dom.scroller.scrollTop=b.dom.grid.left.liner.scrollTop,0<b.s.iRightColumns&&(b.dom.grid.right.liner.scrollTop=b.dom.grid.left.liner.scrollTop))}).on(g,function(a){b.dom.scroller.scrollLeft-="wheel"===a.type?-a.originalEvent.deltaX:a.originalEvent.wheelDeltaX});if(0<b.s.iRightColumns)d(b.dom.grid.right.liner).on("mouseover.DTFC touchstart.DTFC",function(){c="right"}).on("scroll.DTFC",function(){"right"===c&&(b.dom.scroller.scrollTop=
|
||||
b.dom.grid.right.liner.scrollTop,0<b.s.iLeftColumns&&(b.dom.grid.left.liner.scrollTop=b.dom.grid.right.liner.scrollTop))}).on(g,function(a){b.dom.scroller.scrollLeft-="wheel"===a.type?-a.originalEvent.deltaX:a.originalEvent.wheelDeltaX});d(r).on("resize.DTFC",function(){b._fnGridLayout.call(b)});var f=!0,e=d(this.s.dt.nTable);e.on("draw.dt.DTFC",function(){b._fnDraw.call(b,f);f=!1}).on("column-sizing.dt.DTFC",function(){b._fnColCalc();b._fnGridLayout(b)}).on("column-visibility.dt.DTFC",function(){b._fnColCalc();
|
||||
b._fnGridLayout(b);b._fnDraw(!0)}).on("destroy.dt.DTFC",function(){e.off("column-sizing.dt.DTFC destroy.dt.DTFC draw.dt.DTFC");d(b.dom.scroller).off("scroll.DTFC mouseover.DTFC");d(r).off("resize.DTFC");d(b.dom.grid.left.liner).off("scroll.DTFC mouseover.DTFC "+g);d(b.dom.grid.left.wrapper).remove();d(b.dom.grid.right.liner).off("scroll.DTFC mouseover.DTFC "+g);d(b.dom.grid.right.wrapper).remove()});this._fnGridLayout();this.s.dt.oInstance.fnDraw(!1)}},_fnColCalc:function(){var a=this,b=0,c=0;this.s.aiInnerWidths=
|
||||
[];this.s.aiOuterWidths=[];d.each(this.s.dt.aoColumns,function(g,f){var e=d(f.nTh),h;if(e.filter(":visible").length){var i=e.outerWidth();0===a.s.aiOuterWidths.length&&(h=d(a.s.dt.nTable).css("border-left-width"),i+="string"===typeof h?1:parseInt(h,10));a.s.aiOuterWidths.length===a.s.dt.aoColumns.length-1&&(h=d(a.s.dt.nTable).css("border-right-width"),i+="string"===typeof h?1:parseInt(h,10));a.s.aiOuterWidths.push(i);a.s.aiInnerWidths.push(e.width());g<a.s.iLeftColumns&&(b+=i);a.s.iTableColumns-a.s.iRightColumns<=
|
||||
g&&(c+=i)}else a.s.aiInnerWidths.push(0),a.s.aiOuterWidths.push(0)});this.s.iLeftWidth=b;this.s.iRightWidth=c},_fnGridSetup:function(){var a=this._fnDTOverflow(),b;this.dom.body=this.s.dt.nTable;this.dom.header=this.s.dt.nTHead.parentNode;this.dom.header.parentNode.parentNode.style.position="relative";var c=d('<div class="DTFC_ScrollWrapper" style="position:relative; clear:both;"><div class="DTFC_LeftWrapper" style="position:absolute; top:0; left:0;"><div class="DTFC_LeftHeadWrapper" style="position:relative; top:0; left:0; overflow:hidden;"></div><div class="DTFC_LeftBodyWrapper" style="position:relative; top:0; left:0; overflow:hidden;"><div class="DTFC_LeftBodyLiner" style="position:relative; top:0; left:0; overflow-y:scroll;"></div></div><div class="DTFC_LeftFootWrapper" style="position:relative; top:0; left:0; overflow:hidden;"></div></div><div class="DTFC_RightWrapper" style="position:absolute; top:0; left:0;"><div class="DTFC_RightHeadWrapper" style="position:relative; top:0; left:0;"><div class="DTFC_RightHeadBlocker DTFC_Blocker" style="position:absolute; top:0; bottom:0;"></div></div><div class="DTFC_RightBodyWrapper" style="position:relative; top:0; left:0; overflow:hidden;"><div class="DTFC_RightBodyLiner" style="position:relative; top:0; left:0; overflow-y:scroll;"></div></div><div class="DTFC_RightFootWrapper" style="position:relative; top:0; left:0;"><div class="DTFC_RightFootBlocker DTFC_Blocker" style="position:absolute; top:0; bottom:0;"></div></div></div></div>')[0],
|
||||
g=c.childNodes[0],f=c.childNodes[1];this.dom.grid.dt.parentNode.insertBefore(c,this.dom.grid.dt);c.appendChild(this.dom.grid.dt);this.dom.grid.wrapper=c;0<this.s.iLeftColumns&&(this.dom.grid.left.wrapper=g,this.dom.grid.left.head=g.childNodes[0],this.dom.grid.left.body=g.childNodes[1],this.dom.grid.left.liner=d("div.DTFC_LeftBodyLiner",c)[0],c.appendChild(g));0<this.s.iRightColumns&&(this.dom.grid.right.wrapper=f,this.dom.grid.right.head=f.childNodes[0],this.dom.grid.right.body=f.childNodes[1],this.dom.grid.right.liner=
|
||||
d("div.DTFC_RightBodyLiner",c)[0],b=d("div.DTFC_RightHeadBlocker",c)[0],b.style.width=a.bar+"px",b.style.right=-a.bar+"px",this.dom.grid.right.headBlock=b,b=d("div.DTFC_RightFootBlocker",c)[0],b.style.width=a.bar+"px",b.style.right=-a.bar+"px",this.dom.grid.right.footBlock=b,c.appendChild(f));if(this.s.dt.nTFoot&&(this.dom.footer=this.s.dt.nTFoot.parentNode,0<this.s.iLeftColumns&&(this.dom.grid.left.foot=g.childNodes[2]),0<this.s.iRightColumns))this.dom.grid.right.foot=f.childNodes[2]},_fnGridLayout:function(){var a=
|
||||
this.dom.grid,b=d(a.wrapper).width(),c=d(this.s.dt.nTable.parentNode).outerHeight(),g=d(this.s.dt.nTable.parentNode.parentNode).outerHeight(),f=this._fnDTOverflow(),e=this.s.iLeftWidth,h=this.s.iRightWidth,i=function(a,b){f.bar?a.style.width=b+f.bar+"px":(a.style.width=b+20+"px",a.style.paddingRight="20px",a.style.boxSizing="border-box")};f.x&&(c-=f.bar);a.wrapper.style.height=g+"px";0<this.s.iLeftColumns&&(a.left.wrapper.style.width=e+"px",a.left.wrapper.style.height="1px",a.left.body.style.height=
|
||||
c+"px",a.left.foot&&(a.left.foot.style.top=(f.x?f.bar:0)+"px"),i(a.left.liner,e),a.left.liner.style.height=c+"px");0<this.s.iRightColumns&&(b-=h,f.y&&(b-=f.bar),a.right.wrapper.style.width=h+"px",a.right.wrapper.style.left=b+"px",a.right.wrapper.style.height="1px",a.right.body.style.height=c+"px",a.right.foot&&(a.right.foot.style.top=(f.x?f.bar:0)+"px"),i(a.right.liner,h),a.right.liner.style.height=c+"px",a.right.headBlock.style.display=f.y?"block":"none",a.right.footBlock.style.display=f.y?"block":
|
||||
"none")},_fnDTOverflow:function(){var a=this.s.dt.nTable,b=a.parentNode,c={x:!1,y:!1,bar:this.s.dt.oScroll.iBarWidth};a.offsetWidth>b.clientWidth&&(c.x=!0);a.offsetHeight>b.clientHeight&&(c.y=!0);return c},_fnDraw:function(a){this._fnGridLayout();this._fnCloneLeft(a);this._fnCloneRight(a);null!==this.s.fnDrawCallback&&this.s.fnDrawCallback.call(this,this.dom.clone.left,this.dom.clone.right);d(this).trigger("draw.dtfc",{leftClone:this.dom.clone.left,rightClone:this.dom.clone.right})},_fnCloneRight:function(a){if(!(0>=
|
||||
this.s.iRightColumns)){var b,c=[];for(b=this.s.iTableColumns-this.s.iRightColumns;b<this.s.iTableColumns;b++)this.s.dt.aoColumns[b].bVisible&&c.push(b);this._fnClone(this.dom.clone.right,this.dom.grid.right,c,a)}},_fnCloneLeft:function(a){if(!(0>=this.s.iLeftColumns)){var b,c=[];for(b=0;b<this.s.iLeftColumns;b++)this.s.dt.aoColumns[b].bVisible&&c.push(b);this._fnClone(this.dom.clone.left,this.dom.grid.left,c,a)}},_fnCopyLayout:function(a,b){for(var c=[],g=[],f=[],e=0,h=a.length;e<h;e++){var i=[];
|
||||
i.nTr=d(a[e].nTr).clone(!0,!0)[0];for(var k=0,j=this.s.iTableColumns;k<j;k++)if(-1!==d.inArray(k,b)){var m=d.inArray(a[e][k].cell,f);-1===m?(m=d(a[e][k].cell).clone(!0,!0)[0],g.push(m),f.push(a[e][k].cell),i.push({cell:m,unique:a[e][k].unique})):i.push({cell:g[m],unique:a[e][k].unique})}c.push(i)}return c},_fnClone:function(a,b,c,g){var f=this,e,h,i,k,j,m,o,n,q,l=this.s.dt;if(g){null!==a.header&&a.header.parentNode.removeChild(a.header);a.header=d(this.dom.header).clone(!0,!0)[0];a.header.className+=
|
||||
" DTFC_Cloned";a.header.style.width="100%";b.head.appendChild(a.header);n=this._fnCopyLayout(l.aoHeader,c);k=d(">thead",a.header);k.empty();e=0;for(h=n.length;e<h;e++)k[0].appendChild(n[e].nTr);l.oApi._fnDrawHead(l,n,!0)}else{n=this._fnCopyLayout(l.aoHeader,c);q=[];l.oApi._fnDetectHeader(q,d(">thead",a.header)[0]);e=0;for(h=n.length;e<h;e++){i=0;for(k=n[e].length;i<k;i++)q[e][i].cell.className=n[e][i].cell.className,d("span.DataTables_sort_icon",q[e][i].cell).each(function(){this.className=d("span.DataTables_sort_icon",
|
||||
n[e][i].cell)[0].className})}}this._fnEqualiseHeights("thead",this.dom.header,a.header);"auto"==this.s.sHeightMatch&&d(">tbody>tr",f.dom.body).css("height","auto");null!==a.body&&(a.body.parentNode.removeChild(a.body),a.body=null);a.body=d(this.dom.body).clone(!0)[0];a.body.className+=" DTFC_Cloned";a.body.style.paddingBottom=l.oScroll.iBarWidth+"px";a.body.style.marginBottom=2*l.oScroll.iBarWidth+"px";null!==a.body.getAttribute("id")&&a.body.removeAttribute("id");d(">thead>tr",a.body).empty();d(">tfoot",
|
||||
a.body).remove();var p=d("tbody",a.body)[0];d(p).empty();if(0<l.aiDisplay.length){h=d(">thead>tr",a.body)[0];for(o=0;o<c.length;o++)j=c[o],m=d(l.aoColumns[j].nTh).clone(!0)[0],m.innerHTML="",k=m.style,k.paddingTop="0",k.paddingBottom="0",k.borderTopWidth="0",k.borderBottomWidth="0",k.height=0,k.width=f.s.aiInnerWidths[j]+"px",h.appendChild(m);d(">tbody>tr",f.dom.body).each(function(a){var b=this.cloneNode(false);b.removeAttribute("id");a=f.s.dt.aoData[f.s.dt.oFeatures.bServerSide===false?f.s.dt.aiDisplay[f.s.dt._iDisplayStart+
|
||||
a]:a].anCells||d(this).children("td, th");for(o=0;o<c.length;o++){j=c[o];if(a.length>0){m=d(a[j]).clone(true,true)[0];b.appendChild(m)}}p.appendChild(b)})}else d(">tbody>tr",f.dom.body).each(function(){m=this.cloneNode(true);m.className=m.className+" DTFC_NoData";d("td",m).html("");p.appendChild(m)});a.body.style.width="100%";a.body.style.margin="0";a.body.style.padding="0";l.oScroller!==t&&(h=l.oScroller.dom.force,b.forcer?b.forcer.style.height=h.style.height:(b.forcer=h.cloneNode(!0),b.liner.appendChild(b.forcer)));
|
||||
b.liner.appendChild(a.body);this._fnEqualiseHeights("tbody",f.dom.body,a.body);if(null!==l.nTFoot){if(g){null!==a.footer&&a.footer.parentNode.removeChild(a.footer);a.footer=d(this.dom.footer).clone(!0,!0)[0];a.footer.className+=" DTFC_Cloned";a.footer.style.width="100%";b.foot.appendChild(a.footer);n=this._fnCopyLayout(l.aoFooter,c);b=d(">tfoot",a.footer);b.empty();e=0;for(h=n.length;e<h;e++)b[0].appendChild(n[e].nTr);l.oApi._fnDrawHead(l,n,!0)}else{n=this._fnCopyLayout(l.aoFooter,c);b=[];l.oApi._fnDetectHeader(b,
|
||||
d(">tfoot",a.footer)[0]);e=0;for(h=n.length;e<h;e++){i=0;for(k=n[e].length;i<k;i++)b[e][i].cell.className=n[e][i].cell.className}}this._fnEqualiseHeights("tfoot",this.dom.footer,a.footer)}b=l.oApi._fnGetUniqueThs(l,d(">thead",a.header)[0]);d(b).each(function(a){j=c[a];this.style.width=f.s.aiInnerWidths[j]+"px"});null!==f.s.dt.nTFoot&&(b=l.oApi._fnGetUniqueThs(l,d(">tfoot",a.footer)[0]),d(b).each(function(a){j=c[a];this.style.width=f.s.aiInnerWidths[j]+"px"}))},_fnGetTrNodes:function(a){for(var b=
|
||||
[],c=0,d=a.childNodes.length;c<d;c++)"TR"==a.childNodes[c].nodeName.toUpperCase()&&b.push(a.childNodes[c]);return b},_fnEqualiseHeights:function(a,b,c){if(!("none"==this.s.sHeightMatch&&"thead"!==a&&"tfoot"!==a)){var g,f,e=b.getElementsByTagName(a)[0],c=c.getElementsByTagName(a)[0],a=d(">"+a+">tr:eq(0)",b).children(":first");a.outerHeight();a.height();for(var e=this._fnGetTrNodes(e),b=this._fnGetTrNodes(c),h=[],c=0,a=b.length;c<a;c++)g=e[c].offsetHeight,f=b[c].offsetHeight,g=f>g?f:g,"semiauto"==this.s.sHeightMatch&&
|
||||
(e[c]._DTTC_iHeight=g),h.push(g);c=0;for(a=b.length;c<a;c++)b[c].style.height=h[c]+"px",e[c].style.height=h[c]+"px"}}};j.defaults={iLeftColumns:1,iRightColumns:0,fnDrawCallback:null,sHeightMatch:"semiauto"};j.version="3.0.4";d.fn.dataTable.FixedColumns=j;return d.fn.DataTable.FixedColumns=j};"function"===typeof define&&define.amd?define(["jquery","datatables"],p):"object"===typeof exports?p(require("jquery"),require("datatables")):jQuery&&!jQuery.fn.dataTable.FixedColumns&&p(jQuery,jQuery.fn.dataTable)})(window,
|
||||
document);
|
||||
(function(d){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(q){return d(q,window,document)}):"object"===typeof exports?module.exports=function(q,r){q||(q=window);if(!r||!r.fn.dataTable)r=require("datatables.net")(q,r).$;return d(r,q,q.document)}:d(jQuery,window,document)})(function(d,q,r,t){var s=d.fn.dataTable,u,m=function(a,b){var c=this;if(this instanceof m){if(b===t||!0===b)b={};var e=d.fn.dataTable.camelToHungarian;e&&(e(m.defaults,m.defaults,!0),e(m.defaults,
|
||||
b));e=(new d.fn.dataTable.Api(a)).settings()[0];this.s={dt:e,iTableColumns:e.aoColumns.length,aiOuterWidths:[],aiInnerWidths:[]};this.dom={scroller:null,header:null,body:null,footer:null,grid:{wrapper:null,dt:null,left:{wrapper:null,head:null,body:null,foot:null},right:{wrapper:null,head:null,body:null,foot:null}},clone:{left:{header:null,body:null,footer:null},right:{header:null,body:null,footer:null}}};if(e._oFixedColumns)throw"FixedColumns already initialised on this table";e._oFixedColumns=this;
|
||||
e._bInitComplete?this._fnConstruct(b):e.oApi._fnCallbackReg(e,"aoInitComplete",function(){c._fnConstruct(b)},"FixedColumns")}else alert("FixedColumns warning: FixedColumns must be initialised with the 'new' keyword.")};d.extend(m.prototype,{fnUpdate:function(){this._fnDraw(!0)},fnRedrawLayout:function(){this._fnColCalc();this._fnGridLayout();this.fnUpdate()},fnRecalculateHeight:function(a){delete a._DTTC_iHeight;a.style.height="auto"},fnSetRowHeight:function(a,b){a.style.height=b+"px"},fnGetPosition:function(a){var b=
|
||||
this.s.dt.oInstance;if(d(a).parents(".DTFC_Cloned").length){if("tr"===a.nodeName.toLowerCase())return a=d(a).index(),b.fnGetPosition(d("tr",this.s.dt.nTBody)[a]);var c=d(a).index(),a=d(a.parentNode).index();return[b.fnGetPosition(d("tr",this.s.dt.nTBody)[a]),c,b.oApi._fnVisibleToColumnIndex(this.s.dt,c)]}return b.fnGetPosition(a)},_fnConstruct:function(a){var b=this;if("function"!=typeof this.s.dt.oInstance.fnVersionCheck||!0!==this.s.dt.oInstance.fnVersionCheck("1.8.0"))alert("FixedColumns "+m.VERSION+
|
||||
" required DataTables 1.8.0 or later. Please upgrade your DataTables installation");else if(""===this.s.dt.oScroll.sX)this.s.dt.oInstance.oApi._fnLog(this.s.dt,1,"FixedColumns is not needed (no x-scrolling in DataTables enabled), so no action will be taken. Use 'FixedHeader' for column fixing when scrolling is not enabled");else{this.s=d.extend(!0,this.s,m.defaults,a);a=this.s.dt.oClasses;this.dom.grid.dt=d(this.s.dt.nTable).parents("div."+a.sScrollWrapper)[0];this.dom.scroller=d("div."+a.sScrollBody,
|
||||
this.dom.grid.dt)[0];this._fnColCalc();this._fnGridSetup();var c,e=!1;d(this.s.dt.nTableWrapper).on("mousedown.DTFC",function(){e=!0;d(r).one("mouseup",function(){e=!1})});d(this.dom.scroller).on("mouseover.DTFC touchstart.DTFC",function(){e||(c="main")}).on("scroll.DTFC",function(a){!c&&a.originalEvent&&(c="main");if("main"===c&&(0<b.s.iLeftColumns&&(b.dom.grid.left.liner.scrollTop=b.dom.scroller.scrollTop),0<b.s.iRightColumns))b.dom.grid.right.liner.scrollTop=b.dom.scroller.scrollTop});var f="onwheel"in
|
||||
r.createElement("div")?"wheel.DTFC":"mousewheel.DTFC";if(0<b.s.iLeftColumns)d(b.dom.grid.left.liner).on("mouseover.DTFC touchstart.DTFC",function(){e||(c="left")}).on("scroll.DTFC",function(a){!c&&a.originalEvent&&(c="left");"left"===c&&(b.dom.scroller.scrollTop=b.dom.grid.left.liner.scrollTop,0<b.s.iRightColumns&&(b.dom.grid.right.liner.scrollTop=b.dom.grid.left.liner.scrollTop))}).on(f,function(a){b.dom.scroller.scrollLeft-="wheel"===a.type?-a.originalEvent.deltaX:a.originalEvent.wheelDeltaX});
|
||||
if(0<b.s.iRightColumns)d(b.dom.grid.right.liner).on("mouseover.DTFC touchstart.DTFC",function(){e||(c="right")}).on("scroll.DTFC",function(a){!c&&a.originalEvent&&(c="right");"right"===c&&(b.dom.scroller.scrollTop=b.dom.grid.right.liner.scrollTop,0<b.s.iLeftColumns&&(b.dom.grid.left.liner.scrollTop=b.dom.grid.right.liner.scrollTop))}).on(f,function(a){b.dom.scroller.scrollLeft-="wheel"===a.type?-a.originalEvent.deltaX:a.originalEvent.wheelDeltaX});d(q).on("resize.DTFC",function(){b._fnGridLayout.call(b)});
|
||||
var g=!0,h=d(this.s.dt.nTable);h.on("draw.dt.DTFC",function(){b._fnColCalc();b._fnDraw.call(b,g);g=!1}).on("column-sizing.dt.DTFC",function(){b._fnColCalc();b._fnGridLayout(b)}).on("column-visibility.dt.DTFC",function(a,c,d,e,f){if(f===t||f)b._fnColCalc(),b._fnGridLayout(b),b._fnDraw(!0)}).on("select.dt.DTFC deselect.dt.DTFC",function(){b._fnDraw(!1)}).on("destroy.dt.DTFC",function(){h.off(".DTFC");d(b.dom.scroller).off(".DTFC");d(q).off(".DTFC");d(this.s.dt.nTableWrapper).off(".DTFC");d(b.dom.grid.left.liner).off(".DTFC "+
|
||||
f);d(b.dom.grid.left.wrapper).remove();d(b.dom.grid.right.liner).off(".DTFC "+f);d(b.dom.grid.right.wrapper).remove()});this._fnGridLayout();this.s.dt.oInstance.fnDraw(!1)}},_fnColCalc:function(){var a=this,b=0,c=0;this.s.aiInnerWidths=[];this.s.aiOuterWidths=[];d.each(this.s.dt.aoColumns,function(e,f){var g=d(f.nTh),h;if(g.filter(":visible").length){var i=g.outerWidth();0===a.s.aiOuterWidths.length&&(h=d(a.s.dt.nTable).css("border-left-width"),i+="string"===typeof h?1:parseInt(h,10));a.s.aiOuterWidths.length===
|
||||
a.s.dt.aoColumns.length-1&&(h=d(a.s.dt.nTable).css("border-right-width"),i+="string"===typeof h?1:parseInt(h,10));a.s.aiOuterWidths.push(i);a.s.aiInnerWidths.push(g.width());e<a.s.iLeftColumns&&(b+=i);a.s.iTableColumns-a.s.iRightColumns<=e&&(c+=i)}else a.s.aiInnerWidths.push(0),a.s.aiOuterWidths.push(0)});this.s.iLeftWidth=b;this.s.iRightWidth=c},_fnGridSetup:function(){var a=this._fnDTOverflow(),b;this.dom.body=this.s.dt.nTable;this.dom.header=this.s.dt.nTHead.parentNode;this.dom.header.parentNode.parentNode.style.position=
|
||||
"relative";var c=d('<div class="DTFC_ScrollWrapper" style="position:relative; clear:both;"><div class="DTFC_LeftWrapper" style="position:absolute; top:0; left:0;"><div class="DTFC_LeftHeadWrapper" style="position:relative; top:0; left:0; overflow:hidden;"></div><div class="DTFC_LeftBodyWrapper" style="position:relative; top:0; left:0; overflow:hidden;"><div class="DTFC_LeftBodyLiner" style="position:relative; top:0; left:0; overflow-y:scroll;"></div></div><div class="DTFC_LeftFootWrapper" style="position:relative; top:0; left:0; overflow:hidden;"></div></div><div class="DTFC_RightWrapper" style="position:absolute; top:0; right:0;"><div class="DTFC_RightHeadWrapper" style="position:relative; top:0; left:0;"><div class="DTFC_RightHeadBlocker DTFC_Blocker" style="position:absolute; top:0; bottom:0;"></div></div><div class="DTFC_RightBodyWrapper" style="position:relative; top:0; left:0; overflow:hidden;"><div class="DTFC_RightBodyLiner" style="position:relative; top:0; left:0; overflow-y:scroll;"></div></div><div class="DTFC_RightFootWrapper" style="position:relative; top:0; left:0;"><div class="DTFC_RightFootBlocker DTFC_Blocker" style="position:absolute; top:0; bottom:0;"></div></div></div></div>')[0],
|
||||
e=c.childNodes[0],f=c.childNodes[1];this.dom.grid.dt.parentNode.insertBefore(c,this.dom.grid.dt);c.appendChild(this.dom.grid.dt);this.dom.grid.wrapper=c;0<this.s.iLeftColumns&&(this.dom.grid.left.wrapper=e,this.dom.grid.left.head=e.childNodes[0],this.dom.grid.left.body=e.childNodes[1],this.dom.grid.left.liner=d("div.DTFC_LeftBodyLiner",c)[0],c.appendChild(e));0<this.s.iRightColumns&&(this.dom.grid.right.wrapper=f,this.dom.grid.right.head=f.childNodes[0],this.dom.grid.right.body=f.childNodes[1],this.dom.grid.right.liner=
|
||||
d("div.DTFC_RightBodyLiner",c)[0],f.style.right=a.bar+"px",b=d("div.DTFC_RightHeadBlocker",c)[0],b.style.width=a.bar+"px",b.style.right=-a.bar+"px",this.dom.grid.right.headBlock=b,b=d("div.DTFC_RightFootBlocker",c)[0],b.style.width=a.bar+"px",b.style.right=-a.bar+"px",this.dom.grid.right.footBlock=b,c.appendChild(f));if(this.s.dt.nTFoot&&(this.dom.footer=this.s.dt.nTFoot.parentNode,0<this.s.iLeftColumns&&(this.dom.grid.left.foot=e.childNodes[2]),0<this.s.iRightColumns))this.dom.grid.right.foot=f.childNodes[2];
|
||||
"rtl"===d(this.dom.body).css("direction")&&(d(e).css({left:"",right:0}),d(f).css({left:a.bar+"px",right:""}),d("div.DTFC_RightHeadBlocker",c).css({left:-a.bar+"px",right:""}))},_fnGridLayout:function(){var a=this,b=this.dom.grid;d(b.wrapper).width();var c=d(this.s.dt.nTable.parentNode).outerHeight(),e=d(this.s.dt.nTable.parentNode.parentNode).outerHeight(),f=this._fnDTOverflow(),g=this.s.iLeftWidth,h=this.s.iRightWidth,i=function(b,c){f.bar?a._firefoxScrollError()?34<d(b).height()&&(b.style.width=
|
||||
c+f.bar+"px"):b.style.width=c+f.bar+"px":(b.style.width=c+20+"px",b.style.paddingRight="20px",b.style.boxSizing="border-box")};f.x&&(c-=f.bar);b.wrapper.style.height=e+"px";0<this.s.iLeftColumns&&(b.left.wrapper.style.width=g+"px",b.left.wrapper.style.height="1px",b.left.body.style.height=c+"px",b.left.foot&&(b.left.foot.style.top=(f.x?f.bar:0)+"px"),i(b.left.liner,g),b.left.liner.style.height=c+"px");0<this.s.iRightColumns&&(b.right.wrapper.style.width=h+"px",b.right.wrapper.style.height="1px",b.right.body.style.height=
|
||||
c+"px",b.right.foot&&(b.right.foot.style.top=(f.x?f.bar:0)+"px"),i(b.right.liner,h),b.right.liner.style.height=c+"px",b.right.headBlock.style.display=f.y?"block":"none",b.right.footBlock.style.display=f.y?"block":"none")},_fnDTOverflow:function(){var a=this.s.dt.nTable,b=a.parentNode,c={x:!1,y:!1,bar:this.s.dt.oScroll.iBarWidth};a.offsetWidth>b.clientWidth&&(c.x=!0);a.offsetHeight>b.clientHeight&&(c.y=!0);return c},_fnDraw:function(a){this._fnGridLayout();this._fnCloneLeft(a);this._fnCloneRight(a);
|
||||
null!==this.s.fnDrawCallback&&this.s.fnDrawCallback.call(this,this.dom.clone.left,this.dom.clone.right);d(this).trigger("draw.dtfc",{leftClone:this.dom.clone.left,rightClone:this.dom.clone.right})},_fnCloneRight:function(a){if(!(0>=this.s.iRightColumns)){var b,c=[];for(b=this.s.iTableColumns-this.s.iRightColumns;b<this.s.iTableColumns;b++)this.s.dt.aoColumns[b].bVisible&&c.push(b);this._fnClone(this.dom.clone.right,this.dom.grid.right,c,a)}},_fnCloneLeft:function(a){if(!(0>=this.s.iLeftColumns)){var b,
|
||||
c=[];for(b=0;b<this.s.iLeftColumns;b++)this.s.dt.aoColumns[b].bVisible&&c.push(b);this._fnClone(this.dom.clone.left,this.dom.grid.left,c,a)}},_fnCopyLayout:function(a,b,c){for(var e=[],f=[],g=[],h=0,i=a.length;h<i;h++){var k=[];k.nTr=d(a[h].nTr).clone(c,!1)[0];for(var l=0,o=this.s.iTableColumns;l<o;l++)if(-1!==d.inArray(l,b)){var p=d.inArray(a[h][l].cell,g);-1===p?(p=d(a[h][l].cell).clone(c,!1)[0],f.push(p),g.push(a[h][l].cell),k.push({cell:p,unique:a[h][l].unique})):k.push({cell:f[p],unique:a[h][l].unique})}e.push(k)}return e},
|
||||
_fnClone:function(a,b,c,e){var f=this,g,h,i,k,l,o,p,n,m,j=this.s.dt;if(e){d(a.header).remove();a.header=d(this.dom.header).clone(!0,!1)[0];a.header.className+=" DTFC_Cloned";a.header.style.width="100%";b.head.appendChild(a.header);n=this._fnCopyLayout(j.aoHeader,c,!0);k=d(">thead",a.header);k.empty();g=0;for(h=n.length;g<h;g++)k[0].appendChild(n[g].nTr);j.oApi._fnDrawHead(j,n,!0)}else{n=this._fnCopyLayout(j.aoHeader,c,!1);m=[];j.oApi._fnDetectHeader(m,d(">thead",a.header)[0]);g=0;for(h=n.length;g<
|
||||
h;g++){i=0;for(k=n[g].length;i<k;i++)m[g][i].cell.className=n[g][i].cell.className,d("span.DataTables_sort_icon",m[g][i].cell).each(function(){this.className=d("span.DataTables_sort_icon",n[g][i].cell)[0].className})}}this._fnEqualiseHeights("thead",this.dom.header,a.header);"auto"==this.s.sHeightMatch&&d(">tbody>tr",f.dom.body).css("height","auto");null!==a.body&&(d(a.body).remove(),a.body=null);a.body=d(this.dom.body).clone(!0)[0];a.body.className+=" DTFC_Cloned";a.body.style.paddingBottom=j.oScroll.iBarWidth+
|
||||
"px";a.body.style.marginBottom=2*j.oScroll.iBarWidth+"px";null!==a.body.getAttribute("id")&&a.body.removeAttribute("id");d(">thead>tr",a.body).empty();d(">tfoot",a.body).remove();var q=d("tbody",a.body)[0];d(q).empty();if(0<j.aiDisplay.length){h=d(">thead>tr",a.body)[0];for(p=0;p<c.length;p++)l=c[p],o=d(j.aoColumns[l].nTh).clone(!0)[0],o.innerHTML="",k=o.style,k.paddingTop="0",k.paddingBottom="0",k.borderTopWidth="0",k.borderBottomWidth="0",k.height=0,k.width=f.s.aiInnerWidths[l]+"px",h.appendChild(o);
|
||||
d(">tbody>tr",f.dom.body).each(function(a){var a=f.s.dt.oFeatures.bServerSide===false?f.s.dt.aiDisplay[f.s.dt._iDisplayStart+a]:a,b=f.s.dt.aoData[a].anCells||d(this).children("td, th"),e=this.cloneNode(false);e.removeAttribute("id");e.setAttribute("data-dt-row",a);for(p=0;p<c.length;p++){l=c[p];if(b.length>0){o=d(b[l]).clone(true,true)[0];o.setAttribute("data-dt-row",a);o.setAttribute("data-dt-column",p);e.appendChild(o)}}q.appendChild(e)})}else d(">tbody>tr",f.dom.body).each(function(){o=this.cloneNode(true);
|
||||
o.className=o.className+" DTFC_NoData";d("td",o).html("");q.appendChild(o)});a.body.style.width="100%";a.body.style.margin="0";a.body.style.padding="0";j.oScroller!==t&&(h=j.oScroller.dom.force,b.forcer?b.forcer.style.height=h.style.height:(b.forcer=h.cloneNode(!0),b.liner.appendChild(b.forcer)));b.liner.appendChild(a.body);this._fnEqualiseHeights("tbody",f.dom.body,a.body);if(null!==j.nTFoot){if(e){null!==a.footer&&a.footer.parentNode.removeChild(a.footer);a.footer=d(this.dom.footer).clone(!0,!0)[0];
|
||||
a.footer.className+=" DTFC_Cloned";a.footer.style.width="100%";b.foot.appendChild(a.footer);n=this._fnCopyLayout(j.aoFooter,c,!0);b=d(">tfoot",a.footer);b.empty();g=0;for(h=n.length;g<h;g++)b[0].appendChild(n[g].nTr);j.oApi._fnDrawHead(j,n,!0)}else{n=this._fnCopyLayout(j.aoFooter,c,!1);b=[];j.oApi._fnDetectHeader(b,d(">tfoot",a.footer)[0]);g=0;for(h=n.length;g<h;g++){i=0;for(k=n[g].length;i<k;i++)b[g][i].cell.className=n[g][i].cell.className}}this._fnEqualiseHeights("tfoot",this.dom.footer,a.footer)}b=
|
||||
j.oApi._fnGetUniqueThs(j,d(">thead",a.header)[0]);d(b).each(function(a){l=c[a];this.style.width=f.s.aiInnerWidths[l]+"px"});null!==f.s.dt.nTFoot&&(b=j.oApi._fnGetUniqueThs(j,d(">tfoot",a.footer)[0]),d(b).each(function(a){l=c[a];this.style.width=f.s.aiInnerWidths[l]+"px"}))},_fnGetTrNodes:function(a){for(var b=[],c=0,d=a.childNodes.length;c<d;c++)"TR"==a.childNodes[c].nodeName.toUpperCase()&&b.push(a.childNodes[c]);return b},_fnEqualiseHeights:function(a,b,c){if(!("none"==this.s.sHeightMatch&&"thead"!==
|
||||
a&&"tfoot"!==a)){var e,f,g=b.getElementsByTagName(a)[0],c=c.getElementsByTagName(a)[0],a=d(">"+a+">tr:eq(0)",b).children(":first");a.outerHeight();a.height();for(var g=this._fnGetTrNodes(g),b=this._fnGetTrNodes(c),h=[],c=0,a=b.length;c<a;c++)e=g[c].offsetHeight,f=b[c].offsetHeight,e=f>e?f:e,"semiauto"==this.s.sHeightMatch&&(g[c]._DTTC_iHeight=e),h.push(e);c=0;for(a=b.length;c<a;c++)b[c].style.height=h[c]+"px",g[c].style.height=h[c]+"px"}},_firefoxScrollError:function(){if(u===t){var a=d("<div/>").css({position:"absolute",
|
||||
top:0,left:0,height:10,width:50,overflow:"scroll"}).appendTo("body");u=a[0].clientWidth===a[0].offsetWidth&&0!==this._fnDTOverflow().bar;a.remove()}return u}});m.defaults={iLeftColumns:1,iRightColumns:0,fnDrawCallback:null,sHeightMatch:"semiauto"};m.version="3.2.1";s.Api.register("fixedColumns()",function(){return this});s.Api.register("fixedColumns().update()",function(){return this.iterator("table",function(a){a._oFixedColumns&&a._oFixedColumns.fnUpdate()})});s.Api.register("fixedColumns().relayout()",
|
||||
function(){return this.iterator("table",function(a){a._oFixedColumns&&a._oFixedColumns.fnRedrawLayout()})});s.Api.register("rows().recalcHeight()",function(){return this.iterator("row",function(a,b){a._oFixedColumns&&a._oFixedColumns.fnRecalculateHeight(this.row(b).node())})});s.Api.register("fixedColumns().rowIndex()",function(a){a=d(a);return a.parents(".DTFC_Cloned").length?this.rows({page:"current"}).indexes()[a.index()]:this.row(a).index()});s.Api.register("fixedColumns().cellIndex()",function(a){a=
|
||||
d(a);if(a.parents(".DTFC_Cloned").length){var b=a.parent().index(),b=this.rows({page:"current"}).indexes()[b],a=a.parents(".DTFC_LeftWrapper").length?a.index():this.columns().flatten().length-this.context[0]._oFixedColumns.s.iRightColumns+a.index();return{row:b,column:this.column.index("toData",a),columnVisible:a}}return this.cell(a).index()});d(r).on("init.dt.fixedColumns",function(a,b){if("dt"===a.namespace){var c=b.oInit.fixedColumns,e=s.defaults.fixedColumns;if(c||e)e=d.extend({},c,e),!1!==c&&
|
||||
new m(b,e)}});d.fn.dataTable.FixedColumns=m;return d.fn.DataTable.FixedColumns=m});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,30 +1,17 @@
|
||||
/*!
|
||||
FixedHeader 2.1.2
|
||||
©2010-2014 SpryMedia Ltd - datatables.net/license
|
||||
FixedHeader 3.1.1
|
||||
©2009-2016 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
var FixedHeader;
|
||||
(function(j,k,h){var l=function(e){FixedHeader=function(a,b){if(!this instanceof FixedHeader)alert("FixedHeader warning: FixedHeader must be initialised with the 'new' keyword.");else{var c={aoCache:[],oSides:{top:!0,bottom:!1,left:0,right:0},oZIndexes:{top:104,bottom:103,left:102,right:101},oCloneOnDraw:{top:!1,bottom:!1,left:!0,right:!0},oMes:{iTableWidth:0,iTableHeight:0,iTableLeft:0,iTableRight:0,iTableTop:0,iTableBottom:0},oOffset:{top:0},nTable:null,bFooter:!1,bInitComplete:!1};this.fnGetSettings=
|
||||
function(){return c};this.fnUpdate=function(){this._fnUpdateClones();this._fnUpdatePositions()};this.fnPosition=function(){this._fnUpdatePositions()};var d=e.fn.dataTable.Api?(new e.fn.dataTable.Api(a)).settings()[0]:a.fnSettings();d._oPluginFixedHeader=this;this.fnInit(d,b)}};FixedHeader.prototype={fnInit:function(a,b){var c=this.fnGetSettings(),d=this;this.fnInitSettings(c,b);""!==a.oScroll.sX||""!==a.oScroll.sY?alert("FixedHeader 2 is not supported with DataTables' scrolling mode at this time"):
|
||||
(c.nTable=a.nTable,a.aoDrawCallback.unshift({fn:function(){FixedHeader.fnMeasure();d._fnUpdateClones.call(d);d._fnUpdatePositions.call(d)},sName:"FixedHeader"}),c.bFooter=0<e(">tfoot",c.nTable).length?!0:!1,c.oSides.top&&c.aoCache.push(d._fnCloneTable("fixedHeader","FixedHeader_Header",d._fnCloneThead)),c.oSides.bottom&&c.aoCache.push(d._fnCloneTable("fixedFooter","FixedHeader_Footer",d._fnCloneTfoot)),c.oSides.left&&c.aoCache.push(d._fnCloneTable("fixedLeft","FixedHeader_Left",d._fnCloneTLeft,c.oSides.left)),
|
||||
c.oSides.right&&c.aoCache.push(d._fnCloneTable("fixedRight","FixedHeader_Right",d._fnCloneTRight,c.oSides.right)),FixedHeader.afnScroll.push(function(){d._fnUpdatePositions.call(d)}),e(j).resize(function(){FixedHeader.fnMeasure();d._fnUpdateClones.call(d);d._fnUpdatePositions.call(d)}),e(c.nTable).on("column-reorder.dt",function(){FixedHeader.fnMeasure();d._fnUpdateClones(!0);d._fnUpdatePositions()}).on("column-visibility.dt",function(){FixedHeader.fnMeasure();d._fnUpdateClones(!0);d._fnUpdatePositions()}),
|
||||
FixedHeader.fnMeasure(),d._fnUpdateClones(),d._fnUpdatePositions(),c.bInitComplete=!0)},fnInitSettings:function(a,b){if(b!==h&&(b.top!==h&&(a.oSides.top=b.top),b.bottom!==h&&(a.oSides.bottom=b.bottom),"boolean"==typeof b.left?a.oSides.left=b.left?1:0:b.left!==h&&(a.oSides.left=b.left),"boolean"==typeof b.right?a.oSides.right=b.right?1:0:b.right!==h&&(a.oSides.right=b.right),b.zTop!==h&&(a.oZIndexes.top=b.zTop),b.zBottom!==h&&(a.oZIndexes.bottom=b.zBottom),b.zLeft!==h&&(a.oZIndexes.left=b.zLeft),b.zRight!==
|
||||
h&&(a.oZIndexes.right=b.zRight),b.offsetTop!==h&&(a.oOffset.top=b.offsetTop),b.alwaysCloneTop!==h&&(a.oCloneOnDraw.top=b.alwaysCloneTop),b.alwaysCloneBottom!==h&&(a.oCloneOnDraw.bottom=b.alwaysCloneBottom),b.alwaysCloneLeft!==h&&(a.oCloneOnDraw.left=b.alwaysCloneLeft),b.alwaysCloneRight!==h))a.oCloneOnDraw.right=b.alwaysCloneRight},_fnCloneTable:function(a,b,c,d){var f=this.fnGetSettings(),g;"absolute"!=e(f.nTable.parentNode).css("position")&&(f.nTable.parentNode.style.position="relative");g=f.nTable.cloneNode(!1);
|
||||
g.removeAttribute("id");var i=k.createElement("div");i.style.position="absolute";i.style.top="0px";i.style.left="0px";i.className+=" FixedHeader_Cloned "+a+" "+b;"fixedHeader"==a&&(i.style.zIndex=f.oZIndexes.top);"fixedFooter"==a&&(i.style.zIndex=f.oZIndexes.bottom);"fixedLeft"==a?i.style.zIndex=f.oZIndexes.left:"fixedRight"==a&&(i.style.zIndex=f.oZIndexes.right);g.style.margin="0";i.appendChild(g);k.body.appendChild(i);return{nNode:g,nWrapper:i,sType:a,sPosition:"",sTop:"",sLeft:"",fnClone:c,iCells:d}},
|
||||
_fnMeasure:function(){var a=this.fnGetSettings(),b=a.oMes,c=e(a.nTable),d=c.offset(),f=this._fnSumScroll(a.nTable.parentNode,"scrollTop");this._fnSumScroll(a.nTable.parentNode,"scrollLeft");b.iTableWidth=c.outerWidth();b.iTableHeight=c.outerHeight();b.iTableLeft=d.left+a.nTable.parentNode.scrollLeft;b.iTableTop=d.top+f;b.iTableRight=b.iTableLeft+b.iTableWidth;b.iTableRight=FixedHeader.oDoc.iWidth-b.iTableLeft-b.iTableWidth;b.iTableBottom=FixedHeader.oDoc.iHeight-b.iTableTop-b.iTableHeight},_fnSumScroll:function(a,
|
||||
b){for(var c=a[b];(a=a.parentNode)&&!("HTML"==a.nodeName||"BODY"==a.nodeName);)c=a[b];return c},_fnUpdatePositions:function(){var a=this.fnGetSettings();this._fnMeasure();for(var b=0,c=a.aoCache.length;b<c;b++)"fixedHeader"==a.aoCache[b].sType?this._fnScrollFixedHeader(a.aoCache[b]):"fixedFooter"==a.aoCache[b].sType?this._fnScrollFixedFooter(a.aoCache[b]):"fixedLeft"==a.aoCache[b].sType?this._fnScrollHorizontalLeft(a.aoCache[b]):this._fnScrollHorizontalRight(a.aoCache[b])},_fnUpdateClones:function(a){var b=
|
||||
this.fnGetSettings();a&&(b.bInitComplete=!1);for(var c=0,d=b.aoCache.length;c<d;c++)b.aoCache[c].fnClone.call(this,b.aoCache[c]);a&&(b.bInitComplete=!0)},_fnScrollHorizontalRight:function(a){var b=this.fnGetSettings().oMes,c=FixedHeader.oWin,d=FixedHeader.oDoc,f=a.nWrapper,g=e(f).outerWidth();c.iScrollRight<b.iTableRight?(this._fnUpdateCache(a,"sPosition","absolute","position",f.style),this._fnUpdateCache(a,"sTop",b.iTableTop+"px","top",f.style),this._fnUpdateCache(a,"sLeft",b.iTableLeft+b.iTableWidth-
|
||||
g+"px","left",f.style)):b.iTableLeft<d.iWidth-c.iScrollRight-g?(this._fnUpdateCache(a,"sPosition","fixed","position",f.style),this._fnUpdateCache(a,"sTop",b.iTableTop-c.iScrollTop+"px","top",f.style),this._fnUpdateCache(a,"sLeft",c.iWidth-g+"px","left",f.style)):(this._fnUpdateCache(a,"sPosition","absolute","position",f.style),this._fnUpdateCache(a,"sTop",b.iTableTop+"px","top",f.style),this._fnUpdateCache(a,"sLeft",b.iTableLeft+"px","left",f.style))},_fnScrollHorizontalLeft:function(a){var b=this.fnGetSettings().oMes,
|
||||
c=FixedHeader.oWin,d=a.nWrapper,f=e(d).outerWidth();c.iScrollLeft<b.iTableLeft?(this._fnUpdateCache(a,"sPosition","absolute","position",d.style),this._fnUpdateCache(a,"sTop",b.iTableTop+"px","top",d.style),this._fnUpdateCache(a,"sLeft",b.iTableLeft+"px","left",d.style)):c.iScrollLeft<b.iTableLeft+b.iTableWidth-f?(this._fnUpdateCache(a,"sPosition","fixed","position",d.style),this._fnUpdateCache(a,"sTop",b.iTableTop-c.iScrollTop+"px","top",d.style),this._fnUpdateCache(a,"sLeft","0px","left",d.style)):
|
||||
(this._fnUpdateCache(a,"sPosition","absolute","position",d.style),this._fnUpdateCache(a,"sTop",b.iTableTop+"px","top",d.style),this._fnUpdateCache(a,"sLeft",b.iTableLeft+b.iTableWidth-f+"px","left",d.style))},_fnScrollFixedFooter:function(a){var b=this.fnGetSettings(),c=b.oMes,d=FixedHeader.oWin,f=a.nWrapper,b=e("thead",b.nTable).outerHeight(),g=e(f).outerHeight();d.iScrollBottom<c.iTableBottom?(this._fnUpdateCache(a,"sPosition","absolute","position",f.style),this._fnUpdateCache(a,"sTop",c.iTableTop+
|
||||
c.iTableHeight-g+"px","top",f.style),this._fnUpdateCache(a,"sLeft",c.iTableLeft+"px","left",f.style)):d.iScrollBottom<c.iTableBottom+c.iTableHeight-g-b?(this._fnUpdateCache(a,"sPosition","fixed","position",f.style),this._fnUpdateCache(a,"sTop",d.iHeight-g+"px","top",f.style),this._fnUpdateCache(a,"sLeft",c.iTableLeft-d.iScrollLeft+"px","left",f.style)):(this._fnUpdateCache(a,"sPosition","absolute","position",f.style),this._fnUpdateCache(a,"sTop",c.iTableTop+g+"px","top",f.style),this._fnUpdateCache(a,
|
||||
"sLeft",c.iTableLeft+"px","left",f.style))},_fnScrollFixedHeader:function(a){for(var b=this.fnGetSettings(),c=b.oMes,d=FixedHeader.oWin,e=a.nWrapper,g=0,i=b.nTable.getElementsByTagName("tbody"),h=0;h<i.length;++h)g+=i[h].offsetHeight;c.iTableTop>d.iScrollTop+b.oOffset.top?(this._fnUpdateCache(a,"sPosition","absolute","position",e.style),this._fnUpdateCache(a,"sTop",c.iTableTop+"px","top",e.style),this._fnUpdateCache(a,"sLeft",c.iTableLeft+"px","left",e.style)):d.iScrollTop+b.oOffset.top>c.iTableTop+
|
||||
g?(this._fnUpdateCache(a,"sPosition","absolute","position",e.style),this._fnUpdateCache(a,"sTop",c.iTableTop+g+"px","top",e.style),this._fnUpdateCache(a,"sLeft",c.iTableLeft+"px","left",e.style)):(this._fnUpdateCache(a,"sPosition","fixed","position",e.style),this._fnUpdateCache(a,"sTop",b.oOffset.top+"px","top",e.style),this._fnUpdateCache(a,"sLeft",c.iTableLeft-d.iScrollLeft+"px","left",e.style))},_fnUpdateCache:function(a,b,c,d,e){a[b]!=c&&(e[d]=c,a[b]=c)},_fnClassUpdate:function(a,b){var c=this;
|
||||
if("TR"===a.nodeName.toUpperCase()||"TH"===a.nodeName.toUpperCase()||"TD"===a.nodeName.toUpperCase()||"SPAN"===a.nodeName.toUpperCase())b.className=a.className;e(a).children().each(function(d){c._fnClassUpdate(e(a).children()[d],e(b).children()[d])})},_fnCloneThead:function(a){var b=this.fnGetSettings(),c=a.nNode;if(b.bInitComplete&&!b.oCloneOnDraw.top)this._fnClassUpdate(e("thead",b.nTable)[0],e("thead",c)[0]);else{var d=e(b.nTable).outerWidth();a.nWrapper.style.width=d+"px";for(c.style.width=d+
|
||||
"px";0<c.childNodes.length;)e("thead th",c).unbind("click"),c.removeChild(c.childNodes[0]);a=e("thead",b.nTable).clone(!0)[0];c.appendChild(a);var f=[],g=[];e("thead>tr th",b.nTable).each(function(){f.push(e(this).width())});e("thead>tr td",b.nTable).each(function(){g.push(e(this).width())});e("thead>tr th",b.nTable).each(function(a){e("thead>tr th:eq("+a+")",c).width(f[a]);e(this).width(f[a])});e("thead>tr td",b.nTable).each(function(a){e("thead>tr td:eq("+a+")",c).width(g[a]);e(this).width(g[a])});
|
||||
e("th.sorting, th.sorting_desc, th.sorting_asc",c).bind("click",function(){this.blur()})}},_fnCloneTfoot:function(a){var b=this.fnGetSettings(),c=a.nNode;for(a.nWrapper.style.width=e(b.nTable).outerWidth()+"px";0<c.childNodes.length;)c.removeChild(c.childNodes[0]);a=e("tfoot",b.nTable).clone(!0)[0];c.appendChild(a);e("tfoot:eq(0)>tr th",b.nTable).each(function(a){e("tfoot:eq(0)>tr th:eq("+a+")",c).width(e(this).width())});e("tfoot:eq(0)>tr td",b.nTable).each(function(a){e("tfoot:eq(0)>tr td:eq("+
|
||||
a+")",c).width(e(this).width())})},_fnCloneTLeft:function(a){for(var b=this.fnGetSettings(),c=a.nNode,d=e("tbody",b.nTable)[0];0<c.childNodes.length;)c.removeChild(c.childNodes[0]);c.appendChild(e("thead",b.nTable).clone(!0)[0]);c.appendChild(e("tbody",b.nTable).clone(!0)[0]);b.bFooter&&c.appendChild(e("tfoot",b.nTable).clone(!0)[0]);var f="gt("+(a.iCells-1)+")";e("thead tr",c).each(function(){e("th:"+f,this).remove()});e("tfoot tr",c).each(function(){e("th:"+f,this).remove()});e("tbody tr",c).each(function(){e("td:"+
|
||||
f,this).remove()});this.fnEqualiseHeights("thead",d.parentNode,c);this.fnEqualiseHeights("tbody",d.parentNode,c);this.fnEqualiseHeights("tfoot",d.parentNode,c);for(var g=d=0;g<a.iCells;g++)d+=e("thead tr th:eq("+g+")",b.nTable).outerWidth();c.style.width=d+"px";a.nWrapper.style.width=d+"px"},_fnCloneTRight:function(a){for(var b=this.fnGetSettings(),c=e("tbody",b.nTable)[0],d=a.nNode,f=e("tbody tr:eq(0) td",b.nTable).length;0<d.childNodes.length;)d.removeChild(d.childNodes[0]);d.appendChild(e("thead",
|
||||
b.nTable).clone(!0)[0]);d.appendChild(e("tbody",b.nTable).clone(!0)[0]);b.bFooter&&d.appendChild(e("tfoot",b.nTable).clone(!0)[0]);e("thead tr th:lt("+(f-a.iCells)+")",d).remove();e("tfoot tr th:lt("+(f-a.iCells)+")",d).remove();e("tbody tr",d).each(function(){e("td:lt("+(f-a.iCells)+")",this).remove()});this.fnEqualiseHeights("thead",c.parentNode,d);this.fnEqualiseHeights("tbody",c.parentNode,d);this.fnEqualiseHeights("tfoot",c.parentNode,d);for(var g=c=0;g<a.iCells;g++)c+=e("thead tr th:eq("+(f-
|
||||
1-g)+")",b.nTable).outerWidth();d.style.width=c+"px";a.nWrapper.style.width=c+"px"},fnEqualiseHeights:function(a,b,c){var d=e(a+" tr",b),f;e(a+" tr",c).each(function(a){f=d.eq(a).css("height");"Microsoft Internet Explorer"==navigator.appName&&(f=parseInt(f,10)+1);e(this).css("height",f);d.eq(a).css("height",f)})}};FixedHeader.oWin={iScrollTop:0,iScrollRight:0,iScrollBottom:0,iScrollLeft:0,iHeight:0,iWidth:0};FixedHeader.oDoc={iHeight:0,iWidth:0};FixedHeader.afnScroll=[];FixedHeader.fnMeasure=function(){var a=
|
||||
e(j),b=e(k),c=FixedHeader.oWin,d=FixedHeader.oDoc;d.iHeight=b.height();d.iWidth=b.width();c.iHeight=a.height();c.iWidth=a.width();c.iScrollTop=a.scrollTop();c.iScrollLeft=a.scrollLeft();c.iScrollRight=d.iWidth-c.iScrollLeft-c.iWidth;c.iScrollBottom=d.iHeight-c.iScrollTop-c.iHeight};FixedHeader.version="2.1.2";e(j).scroll(function(){FixedHeader.fnMeasure();for(var a=0,b=FixedHeader.afnScroll.length;a<b;a++)FixedHeader.afnScroll[a]()});e.fn.dataTable.FixedHeader=FixedHeader;return e.fn.DataTable.FixedHeader=
|
||||
FixedHeader};"function"===typeof define&&define.amd?define(["jquery","datatables"],l):"object"===typeof exports?l(require("jquery"),require("datatables")):jQuery&&!jQuery.fn.dataTable.FixedHeader&&l(jQuery,jQuery.fn.dataTable)})(window,document);
|
||||
(function(d){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(g){return d(g,window,document)}):"object"===typeof exports?module.exports=function(g,h){g||(g=window);if(!h||!h.fn.dataTable)h=require("datatables.net")(g,h).$;return d(h,g,g.document)}:d(jQuery,window,document)})(function(d,g,h,k){var j=d.fn.dataTable,l=0,i=function(b,a){if(!(this instanceof i))throw"FixedHeader must be initialised with the 'new' keyword.";!0===a&&(a={});b=new j.Api(b);this.c=d.extend(!0,
|
||||
{},i.defaults,a);this.s={dt:b,position:{theadTop:0,tbodyTop:0,tfootTop:0,tfootBottom:0,width:0,left:0,tfootHeight:0,theadHeight:0,windowHeight:d(g).height(),visible:!0},headerMode:null,footerMode:null,autoWidth:b.settings()[0].oFeatures.bAutoWidth,namespace:".dtfc"+l++,scrollLeft:{header:-1,footer:-1},enable:!0};this.dom={floatingHeader:null,thead:d(b.table().header()),tbody:d(b.table().body()),tfoot:d(b.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 e=b.settings()[0];if(e._fixedHeader)throw"FixedHeader already initialised on table "+e.nTable.id;e._fixedHeader=this;this._constructor()};d.extend(i.prototype,{enable:function(b){this.s.enable=b;this.c.header&&this._modeChange("in-place","header",!0);this.c.footer&&this.dom.tfoot.length&&this._modeChange("in-place","footer",!0);this.update()},headerOffset:function(b){b!==k&&(this.c.headerOffset=
|
||||
b,this.update());return this.c.headerOffset},footerOffset:function(b){b!==k&&(this.c.footerOffset=b,this.update());return this.c.footerOffset},update:function(){this._positions();this._scroll(!0)},_constructor:function(){var b=this,a=this.s.dt;d(g).on("scroll"+this.s.namespace,function(){b._scroll()}).on("resize"+this.s.namespace,function(){b.s.position.windowHeight=d(g).height();b.update()});a.on("column-reorder.dt.dtfc column-visibility.dt.dtfc draw.dt.dtfc column-sizing.dt.dtfc",function(){b.update()});
|
||||
a.on("destroy.dtfc",function(){a.off(".dtfc");d(g).off(b.s.namespace)});this._positions();this._scroll()},_clone:function(b,a){var e=this.s.dt,c=this.dom[b],f="header"===b?this.dom.thead:this.dom.tfoot;!a&&c.floating?c.floating.removeClass("fixedHeader-floating fixedHeader-locked"):(c.floating&&(c.placeholder.remove(),this._unsize(b),c.floating.children().detach(),c.floating.remove()),c.floating=d(e.table().node().cloneNode(!1)).css("table-layout","fixed").removeAttr("id").append(f).appendTo("body"),
|
||||
c.placeholder=f.clone(!1),c.host.prepend(c.placeholder),this._matchWidths(c.placeholder,c.floating))},_matchWidths:function(b,a){var e=function(a){return d(a,b).map(function(){return d(this).width()}).toArray()},c=function(b,c){d(b,a).each(function(a){d(this).css({width:c[a],minWidth:c[a]})})},f=e("th"),e=e("td");c("th",f);c("td",e)},_unsize:function(b){var a=this.dom[b].floating;a&&("footer"===b||"header"===b&&!this.s.autoWidth)?d("th, td",a).css({width:"",minWidth:""}):a&&"header"===b&&d("th, td",
|
||||
a).css("min-width","")},_horizontal:function(b,a){var e=this.dom[b],c=this.s.position,d=this.s.scrollLeft;e.floating&&d[b]!==a&&(e.floating.css("left",c.left-a),d[b]=a)},_modeChange:function(b,a,d){var c=this.dom[a],f=this.s.position;if("in-place"===b){if(c.placeholder&&(c.placeholder.remove(),c.placeholder=null),this._unsize(a),"header"===a?c.host.prepend(this.dom.thead):c.host.append(this.dom.tfoot),c.floating)c.floating.remove(),c.floating=null}else"in"===b?(this._clone(a,d),c.floating.addClass("fixedHeader-floating").css("header"===
|
||||
a?"top":"bottom",this.c[a+"Offset"]).css("left",f.left+"px").css("width",f.width+"px"),"footer"===a&&c.floating.css("top","")):"below"===b?(this._clone(a,d),c.floating.addClass("fixedHeader-locked").css("top",f.tfootTop-f.theadHeight).css("left",f.left+"px").css("width",f.width+"px")):"above"===b&&(this._clone(a,d),c.floating.addClass("fixedHeader-locked").css("top",f.tbodyTop).css("left",f.left+"px").css("width",f.width+"px"));this.s.scrollLeft.header=-1;this.s.scrollLeft.footer=-1;this.s[a+"Mode"]=
|
||||
b},_positions:function(){var b=this.s.dt.table(),a=this.s.position,e=this.dom,b=d(b.node()),c=b.children("thead"),f=b.children("tfoot"),e=e.tbody;a.visible=b.is(":visible");a.width=b.outerWidth();a.left=b.offset().left;a.theadTop=c.offset().top;a.tbodyTop=e.offset().top;a.theadHeight=a.tbodyTop-a.theadTop;f.length?(a.tfootTop=f.offset().top,a.tfootBottom=a.tfootTop+f.outerHeight(),a.tfootHeight=a.tfootBottom-a.tfootTop):(a.tfootTop=a.tbodyTop+e.outerHeight(),a.tfootBottom=a.tfootTop,a.tfootHeight=
|
||||
a.tfootTop)},_scroll:function(b){var a=d(h).scrollTop(),e=d(h).scrollLeft(),c=this.s.position,f;if(this.s.enable&&(this.c.header&&(f=!c.visible||a<=c.theadTop-this.c.headerOffset?"in-place":a<=c.tfootTop-c.theadHeight-this.c.headerOffset?"in":"below",(b||f!==this.s.headerMode)&&this._modeChange(f,"header",b),this._horizontal("header",e)),this.c.footer&&this.dom.tfoot.length))a=!c.visible||a+c.windowHeight>=c.tfootBottom+this.c.footerOffset?"in-place":c.windowHeight+a>c.tbodyTop+c.tfootHeight+this.c.footerOffset?
|
||||
"in":"above",(b||a!==this.s.footerMode)&&this._modeChange(a,"footer",b),this._horizontal("footer",e)}});i.version="3.1.1";i.defaults={header:!0,footer:!1,headerOffset:0,footerOffset:0};d.fn.dataTable.FixedHeader=i;d.fn.DataTable.FixedHeader=i;d(h).on("init.dt.dtfh",function(b,a){if("dt"===b.namespace){var e=a.oInit.fixedHeader,c=j.defaults.fixedHeader;if((e||c)&&!a._fixedHeader)c=d.extend({},c,e),!1!==e&&new i(a,c)}});j.Api.register("fixedHeader()",function(){});j.Api.register("fixedHeader.adjust()",
|
||||
function(){return this.iterator("table",function(b){(b=b._fixedHeader)&&b.update()})});j.Api.register("fixedHeader.enable()",function(b){return this.iterator("table",function(a){(a=a._fixedHeader)&&a.enable(b!==k?b:!0)})});j.Api.register("fixedHeader.disable()",function(){return this.iterator("table",function(b){(b=b._fixedHeader)&&b.enable(!1)})});d.each(["header","footer"],function(b,a){j.Api.register("fixedHeader."+a+"Offset()",function(b){var c=this.context;return b===k?c.length&&c[0]._fixedHeader?
|
||||
c[0]._fixedHeader[a+"Offset"]():k:this.iterator("table",function(c){if(c=c._fixedHeader)c[a+"Offset"](b)})})});return i});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,18 +1,18 @@
|
||||
/*!
|
||||
KeyTable 1.2.1
|
||||
©2010-2014 SpryMedia Ltd - datatables.net/license
|
||||
KeyTable 2.1.1
|
||||
©2009-2016 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
var KeyTable;
|
||||
(function(F,n,K){var A=function(d){KeyTable=function(j){function A(a){return function(e,c,p){(null===e||"number"==typeof e)&&(null===c||"number"==typeof c)&&"function"==typeof p?k[a].push({x:e,y:c,fn:p}):"object"==typeof e&&"function"==typeof c?(e=E(e),k[a].push({x:e[0],y:e[1],fn:c})):alert("Unhandable event type was added: x"+e+" y:"+c+" z:"+p)}}function L(a){return function(e,c,p){(null===e||"number"==typeof e)&&(null===c||"number"==typeof c)?"function"==typeof p?B(a,e,c,p):B(a,e,c):"object"==
|
||||
typeof e?(e=E(e),"function"==typeof c?B(a,e[0],e[1],c):B(a,e[0],e[1])):alert("Unhandable event type was removed: x"+e+" y:"+c+" z:"+p)}}function B(a,e,c,p){for(var h=0,b=0,d=k[a].length;b<d-h;b++)if("undefined"!=typeof p)k[a][b-h].x==e&&(k[a][b-h].y==c&&k[a][b-h].fn==p)&&(k[a].splice(b-h,1),h++);else if(k[a][b-h].x==e&&k[a][b-h].y==c)return k[a].splice(b,1),1;return h}function C(a,e,c){for(var p=0,a=k[a],b=0;b<a.length;b++)if(a[b].x==e&&a[b].y==c||null===a[b].x&&a[b].y==c||a[b].x==e&&null===a[b].y||
|
||||
null===a[b].x&&null===a[b].y)a[b].fn(w(e,c),e,c),p++;return p}function q(a,e){if(t!=a){"undefined"==typeof e&&(e=!0);null!==t&&G(t);d(a).addClass(x);d(a).parent().addClass(x);var c;if(i){c=i;for(var b=H(a)[1],h=o;b>=c.fnDisplayEnd();)0<=c._iDisplayLength?c._iDisplayStart+c._iDisplayLength<c.fnRecordsDisplay()&&(c._iDisplayStart+=c._iDisplayLength):c._iDisplayStart=0,i.oApi._fnCalculateEnd(c);for(;b<c._iDisplayStart;)c._iDisplayStart=0<=c._iDisplayLength?c._iDisplayStart-c._iDisplayLength:0,0>c._iDisplayStart&&
|
||||
(c._iDisplayStart=0),i.oApi._fnCalculateEnd(c);i.oApi._fnDraw(c);o=h}b=E(a);t=a;l=b[0];g=b[1];var r,j,k,m,f;if(e){r=d(F).height();b=d(F).width();j=d(n).scrollTop();h=d(n).scrollLeft();k=a.offsetHeight;m=a.offsetWidth;f=a;var q=0,s=0;if(f.offsetParent){q=f.offsetLeft;s=f.offsetTop;for(f=f.offsetParent;f;)q+=f.offsetLeft,s+=f.offsetTop,f=f.offsetParent}f=[q,s];if(i&&"undefined"!=typeof c.oScroll&&(""!==c.oScroll.sX||""!==c.oScroll.sY))f[1]-=d(c.nTable.parentNode).scrollTop(),f[0]-=d(c.nTable.parentNode).scrollLeft();
|
||||
f[1]+k>j+r?(r=f[1]+k-r,n.documentElement.scrollTop=r,n.body.scrollTop=r):f[1]<j&&(r=f[1],n.documentElement.scrollTop=r,n.body.scrollTop=r);f[0]+m>h+b?(b=f[0]+m-b,n.documentElement.scrollLeft=b,n.body.scrollLeft=b):f[0]<h&&(b=f[0],n.documentElement.scrollLeft=b,n.body.scrollLeft=b)}if(i&&"undefined"!=typeof c.oScroll&&(""!==c.oScroll.sX||""!==c.oScroll.sY))(c=c.nTable.parentNode,r=c.clientHeight,b=c.clientWidth,j=c.scrollTop,h=c.scrollLeft,k=a.offsetHeight,m=a.offsetWidth,a.offsetTop+k>r+j?c.scrollTop=
|
||||
a.offsetTop+k-r:a.offsetTop<j&&(c.scrollTop=a.offsetTop),a.offsetLeft+m>b+h)?c.scrollLeft=a.offsetLeft+m-b:a.offsetLeft<h&&(c.scrollLeft=a.offsetLeft);o||(o=!0);C("focus",l,g)}}function y(){G(t);t=g=l=null;o=!1}function G(a){d(a).removeClass(x);d(a).parent().removeClass(x);C("blur",l,g)}function I(){for(var a=this;"TD"!=a.nodeName;)a=a.parentNode;q(a);o||(o=!0)}function w(a,b){return i?"undefined"!=typeof i.aoData[i.aiDisplay[b]]?i.aoData[i.aiDisplay[b]].nTr.getElementsByTagName("td")[a]:null:d("tr:eq("+
|
||||
b+")>td:eq("+a+")",z)[0]}function E(a){return i?[d("td",a.parentNode).index(a),d("tr",a.parentNode.parentNode).index(a.parentNode)+i._iDisplayStart]:[d("td",a.parentNode).index(a),d("tr",a.parentNode.parentNode).index(a.parentNode)]}function H(a){for(var b=0,c=i.aiDisplay.length;b<c;b++)for(var d=i.aoData[i.aiDisplay[b]].nTr.getElementsByTagName("td"),h=0,g=d.length;h<g;h++)if(d[h]==a)return[h,b];return null}this.block=!1;this.event={remove:{}};this.fnGetCurrentPosition=function(){return[l,g]};this.fnGetCurrentData=
|
||||
function(){return t.innerHTML};this.fnGetCurrentTD=function(){return t};this.fnSetPosition=function(a,b){"object"==typeof a&&a.nodeName?q(a):q(w(a,b))};this.fnBlur=function(){y()};var z=null,t=null,l=null,g=null,J=null,x="focus",o=!1,k={action:[],esc:[],focus:[],blur:[]},i=null,D,s,u=!1,m;for(m in k)m&&(this.event[m]=A(m),this.event.remove[m]=L(m));var v;j===K?(m=d("table.KeyTable")[0],v=null):d.isPlainObject(j)?(m=j.table,v=j.datatable):(v=(new d.fn.dataTable.Api(j)).settings()[0],m=v.nTable);var b=
|
||||
j,J=this;"undefined"==typeof b&&(b={});"undefined"==typeof b.focus&&(b.focus=[0,0]);b.table=m;d(b.table).addClass("KeyTable");"undefined"!=typeof b.focusClass&&(x=b.focusClass);"undefined"!=typeof v&&(i=v);"undefined"==typeof b.initScroll&&(b.initScroll=!0);"undefined"==typeof b.form&&(b.form=!1);D=b.form;z=b.table.getElementsByTagName("tbody")[0];D?(j=n.createElement("div"),s=n.createElement("input"),j.style.height="1px",j.style.width="0px",j.style.overflow="hidden","undefined"!=typeof b.tabIndex&&
|
||||
(s.tabIndex=b.tabIndex),j.appendChild(s),b.table.parentNode.insertBefore(j,b.table.nextSibling),d(s).focus(function(){if(!u){o=true;u=false;typeof b.focus.nodeName!="undefined"?q(b.focus,b.initScroll):q(w(b.focus[0],b.focus[1]),b.initScroll);setTimeout(function(){s.blur()},0)}}),o=!1):("undefined"!=typeof b.focus.nodeName?q(b.focus,b.initScroll):q(w(b.focus[0],b.focus[1]),b.initScroll),o||(o=!0));d(n).bind("keydown",function(a){if(J.block||!o||a.metaKey||a.altKey||a.ctrlKey)return true;var b;b=z.getElementsByTagName("tr")[0].getElementsByTagName("td").length;
|
||||
var c;if(i){c=i.aiDisplay.length;var d=H(t);if(d===null)return;l=d[0];g=d[1]}else c=z.getElementsByTagName("tr").length;d=a.keyCode==9&&a.shiftKey?-1:a.keyCode;switch(d){case 13:a.preventDefault();a.stopPropagation();C("action",l,g);return true;case 27:if(!C("esc",l,g)){y();return}a=l;b=g;break;case -1:case 37:if(l>0){a=l-1;b=g}else if(g>0){a=b-1;b=g-1}else{if(d==-1&&D){u=true;s.focus();setTimeout(function(){u=false},0);o=false;y();return true}return false}break;case 38:if(g>0){a=l;b=g-1}else return false;
|
||||
break;case 36:a=l;b=0;break;case 33:a=l;b=g-10;b<0&&(b=0);break;case 9:case 39:if(l<b-1){a=l+1;b=g}else if(g<c-1){a=0;b=g+1}else{if(d==9&&D){u=true;s.focus();setTimeout(function(){u=false},0);o=false;y();return true}return false}break;case 40:if(g<c-1){a=l;b=g+1}else return false;break;case 35:a=l;b=c-1;break;case 34:a=l;b=g+10;b>c-1&&(b=c-1);break;default:return true}q(w(a,b));return false});if(i)d(i.nTable).on("click","td",I);else d(z).on("click","td",I);d(n).click(function(a){for(var a=a.target,
|
||||
d=false;a;){if(a==b.table){d=true;break}a=a.parentNode}d||y()})};KeyTable.version="1.2.1";d.fn.dataTable.KeyTable=KeyTable;return d.fn.DataTable.KeyTable=KeyTable};"function"===typeof define&&define.amd?define(["jquery","datatables"],A):"object"===typeof exports?A(require("jquery"),require("datatables")):jQuery&&!jQuery.fn.dataTable.KeyTable&&A(jQuery,jQuery.fn.dataTable)})(window,document);
|
||||
(function(f){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(h){return f(h,window,document)}):"object"===typeof exports?module.exports=function(h,i){h||(h=window);if(!i||!i.fn.dataTable)i=require("datatables.net")(h,i).$;return f(i,h,h.document)}:f(jQuery,window,document)})(function(f,h,i,m){var g=f.fn.dataTable,k=function(a,b){if(!g.versionCheck||!g.versionCheck("1.10.8"))throw"KeyTable requires DataTables 1.10.8 or newer";this.c=f.extend(!0,{},g.defaults.keyTable,
|
||||
k.defaults,b);this.s={dt:new g.Api(a),enable:!0,focusDraw:!1};this.dom={};var d=this.s.dt.settings()[0],c=d.keytable;if(c)return c;d.keytable=this;this._constructor()};f.extend(k.prototype,{blur:function(){this._blur()},enable:function(a){this.s.enable=a},focus:function(a,b){this._focus(this.s.dt.cell(a,b))},focused:function(a){if(!this.s.lastFocus)return!1;var b=this.s.lastFocus.index();return a.row===b.row&&a.column===b.column},_constructor:function(){this._tabInput();var a=this,b=this.s.dt,d=f(b.table().node());
|
||||
"static"===d.css("position")&&d.css("position","relative");f(b.table().body()).on("click.keyTable","th, td",function(){if(!1!==a.s.enable){var c=b.cell(this);c.any()&&a._focus(c)}});f(i).on("keydown.keyTable",function(b){a._key(b)});if(this.c.blurable)f(i).on("click.keyTable",function(c){f(c.target).parents(".dataTables_filter").length&&a._blur();f(c.target).parents().filter(b.table().container()).length||f(c.target).parents("div.DTE").length||a._blur()});if(this.c.editor)b.on("key.keyTable",function(b,
|
||||
c,d,f,i){a._editor(d,i)});if(b.settings()[0].oFeatures.bStateSave)b.on("stateSaveParams.keyTable",function(b,c,d){d.keyTable=a.s.lastFocus?a.s.lastFocus.index():null});b.on("xhr.keyTable",function(){if(!a.s.focusDraw){var c=a.s.lastFocus;c&&(a.s.lastFocus=null,b.one("draw",function(){a._focus(c)}))}});b.on("destroy.keyTable",function(){b.off(".keyTable");f(b.table().body()).off("click.keyTable","th, td");f(i.body).off("keydown.keyTable").off("click.keyTable")});var c=b.state.loaded();if(c&&c.keyTable)b.one("init",
|
||||
function(){var a=b.cell(c.keyTable);a.any()&&a.focus()});else this.c.focus&&b.cell(this.c.focus).focus()},_blur:function(){if(this.s.enable&&this.s.lastFocus){var a=this.s.lastFocus;f(a.node()).removeClass(this.c.className);this.s.lastFocus=null;this._emitEvent("key-blur",[this.s.dt,a])}},_columns:function(){var a=this.s.dt,b=a.columns(this.c.columns).indexes(),d=[];a.columns(":visible").every(function(a){-1!==b.indexOf(a)&&d.push(a)});return d},_editor:function(a,b){var d=this.s.dt,c=this.c.editor;
|
||||
b.stopPropagation();c.inline(this.s.lastFocus.index());var e=f("div.DTE input, div.DTE textarea");e.length&&e[0].select();d.keys.enable("navigation-only");d.one("key-blur.editor",function(){c.displayed()&&c.submit()});c.one("close",function(){d.keys.enable(!0);d.off("key-blur.editor")})},_emitEvent:function(a,b){this.s.dt.iterator("table",function(d){f(d.nTable).triggerHandler(a,b)})},_focus:function(a,b){var d=this,c=this.s.dt,e=c.page.info(),l=this.s.lastFocus;if(this.s.enable){if("number"!==typeof a){var j=
|
||||
a.index(),b=j.column,a=c.rows({filter:"applied",order:"applied"}).indexes().indexOf(j.row);e.serverSide&&(a+=e.start)}if(-1!==e.length&&(a<e.start||a>=e.start+e.length))this.s.focusDraw=!0,c.one("draw",function(){d.s.focusDraw=!1;d._focus(a,b)}).page(Math.floor(a/e.length)).draw(!1);else if(-1!==f.inArray(b,this._columns())){e.serverSide&&(a-=e.start);e=c.cell(":eq("+a+")",b,{search:"applied"});if(l){if(l.node()===e.node())return;this._blur()}l=f(e.node());l.addClass(this.c.className);this._scroll(f(h),
|
||||
f(i.body),l,"offset");j=c.table().body().parentNode;j!==c.table().header().parentNode&&(j=f(j.parentNode),this._scroll(j,j,l,"position"));this.s.lastFocus=e;this._emitEvent("key-focus",[this.s.dt,e]);c.state.save()}}},_key:function(a){if(this.s.enable&&!(0===a.keyCode||a.ctrlKey||a.metaKey||a.altKey)){var b=this.s.lastFocus;if(b){var d=this,c=this.s.dt;if(!(this.c.keys&&-1===f.inArray(a.keyCode,this.c.keys)))switch(a.keyCode){case 9:this._shift(a,a.shiftKey?"left":"right",!0);break;case 27:this.s.blurable&&
|
||||
!0===this.s.enable&&this._blur();break;case 33:case 34:a.preventDefault();var e=c.cells({page:"current"}).nodes().indexOf(b.node());c.one("draw",function(){var a=c.cells({page:"current"}).nodes();d._focus(c.cell(e<a.length?a[e]:a[a.length-1]))}).page(33===a.keyCode?"previous":"next").draw(!1);break;case 35:case 36:a.preventDefault();b=c.cells({page:"current"}).indexes();this._focus(c.cell(b[35===a.keyCode?b.length-1:0]));break;case 37:this._shift(a,"left");break;case 38:this._shift(a,"up");break;
|
||||
case 39:this._shift(a,"right");break;case 40:this._shift(a,"down");break;default:!0===this.s.enable&&this._emitEvent("key",[c,a.keyCode,this.s.lastFocus,a])}}}},_scroll:function(a,b,d,c){var c=d[c](),e=d.outerHeight(),d=d.outerWidth(),f=b.scrollTop(),j=b.scrollLeft(),i=a.height(),a=a.width();c.top<f&&b.scrollTop(c.top);c.left<j&&b.scrollLeft(c.left);c.top+e>f+i&&b.scrollTop(c.top+e-i);c.left+d>j+a&&b.scrollLeft(c.left+d-a)},_shift:function(a,b,d){var c=this.s.dt,e=c.page.info(),i=e.recordsDisplay,
|
||||
j=this.s.lastFocus,g=this._columns();if(j){var h=c.rows({filter:"applied",order:"applied"}).indexes().indexOf(j.index().row);e.serverSide&&(h+=e.start);c=c.columns(g).indexes().indexOf(j.index().column);e=g[c];"right"===b?c>=g.length-1?(h++,e=g[0]):e=g[c+1]:"left"===b?0===c?(h--,e=g[g.length-1]):e=g[c-1]:"up"===b?h--:"down"===b&&h++;0<=h&&h<i&&-1!==f.inArray(e,g)?(a.preventDefault(),this._focus(h,e)):!d||!this.c.blurable?a.preventDefault():this._blur()}},_tabInput:function(){var a=this,b=this.s.dt,
|
||||
d=null!==this.c.tabIndex?this.c.tabIndex:b.settings()[0].iTabIndex;if(-1!=d)f('<div><input type="text" tabindex="'+d+'"/></div>').css({position:"absolute",height:1,width:0,overflow:"hidden"}).insertBefore(b.table().node()).children().on("focus",function(){a._focus(b.cell(":eq(0)","0:visible",{page:"current"}))})}});k.defaults={blurable:!0,className:"focus",columns:"",editor:null,focus:null,keys:null,tabIndex:null};k.version="2.1.1";f.fn.dataTable.KeyTable=k;f.fn.DataTable.KeyTable=k;g.Api.register("cell.blur()",
|
||||
function(){return this.iterator("table",function(a){a.keytable&&a.keytable.blur()})});g.Api.register("cell().focus()",function(){return this.iterator("cell",function(a,b,d){a.keytable&&a.keytable.focus(b,d)})});g.Api.register("keys.disable()",function(){return this.iterator("table",function(a){a.keytable&&a.keytable.enable(!1)})});g.Api.register("keys.enable()",function(a){return this.iterator("table",function(b){b.keytable&&b.keytable.enable(a===m?!0:a)})});g.ext.selector.cell.push(function(a,b,
|
||||
d){var b=b.focused,a=a.keytable,c=[];if(!a||b===m)return d;for(var e=0,f=d.length;e<f;e++)(!0===b&&a.focused(d[e])||!1===b&&!a.focused(d[e]))&&c.push(d[e]);return c});f(i).on("preInit.dt.dtk",function(a,b){if("dt"===a.namespace){var d=b.oInit.keys,c=g.defaults.keys;if(d||c)c=f.extend({},d,c),!1!==d&&new k(b,c)}});return k});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
MIT license
|
||||
|
||||
Copyright (c) 2014-2015 SpryMedia Limited
|
||||
http://datatables.net
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# Responsive
|
||||
|
||||
Responsive will automatically optimise the table's layout for different screen sizes through the dynamic column visibility control, making your tables useful on desktop and mobile screens.
|
||||
|
||||
|
||||
# Installation
|
||||
|
||||
To use Responsive the primary way to obtain the software is to use the [DataTables downloader](//datatables.net/download). You can also include the individual files from the [DataTables CDN](//cdn.datatables.net). See the [documentation](http://datatables.net/extensions/responsive/) for full details.
|
||||
|
||||
## NPM and Bower
|
||||
|
||||
If you prefer to use a package manager such as NPM or Bower, distribution repositories are available with software built from this repository under the name `datatables.net-responsive`. Styling packages for Bootstrap, Foundation and other styling libraries are also available by adding a suffix to the package name.
|
||||
|
||||
Please see the DataTables [NPM](//datatables.net/download/npm) and [Bower](//datatables.net/download/bower) installation pages for further information. The [DataTables installation manual](//datatables.net/manual/installation) also has details on how to use package managers with DataTables.
|
||||
|
||||
|
||||
# Basic usage
|
||||
|
||||
Responsive is initialised using the `responsive` option in the DataTables constructor - a simple boolean `true` will enable the feature. Further options can be specified using this option as an object - see the documentation for details.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
$(document).ready( function () {
|
||||
$('#myTable').DataTable( {
|
||||
responsive: true
|
||||
} );
|
||||
} );
|
||||
```
|
||||
|
||||
|
||||
# Documentation / support
|
||||
|
||||
* [Documentation](https://datatables.net/extensions/responsive/)
|
||||
* [DataTables support forums](http://datatables.net/forums)
|
||||
|
||||
|
||||
# GitHub
|
||||
|
||||
If you fancy getting involved with the development of Responsive and help make it better, please refer to its [GitHub repo](https://github.com/DataTables/Responsive).
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*! Responsive 1.0.6
|
||||
* 2014-2015 SpryMedia Ltd - datatables.net/license
|
||||
/*! Responsive 2.0.2
|
||||
* 2014-2016 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @summary Responsive
|
||||
* @description Responsive tables plug-in for DataTables
|
||||
* @version 1.0.6
|
||||
* @version 2.0.2
|
||||
* @file dataTables.responsive.js
|
||||
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
||||
* @contact www.sprymedia.co.uk/contact
|
||||
* @copyright Copyright 2014-2015 SpryMedia Ltd.
|
||||
* @copyright Copyright 2014-2016 SpryMedia Ltd.
|
||||
*
|
||||
* This source file is free software, available under the following license:
|
||||
* MIT license - http://datatables.net/license/mit
|
||||
@@ -20,12 +20,35 @@
|
||||
*
|
||||
* For details please refer to: http://www.datatables.net
|
||||
*/
|
||||
(function( factory ){
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( ['jquery', 'datatables.net'], function ( $ ) {
|
||||
return factory( $, window, document );
|
||||
} );
|
||||
}
|
||||
else if ( typeof exports === 'object' ) {
|
||||
// CommonJS
|
||||
module.exports = function (root, $) {
|
||||
if ( ! root ) {
|
||||
root = window;
|
||||
}
|
||||
|
||||
(function(window, document, undefined) {
|
||||
if ( ! $ || ! $.fn.dataTable ) {
|
||||
$ = require('datatables.net')(root, $).$;
|
||||
}
|
||||
|
||||
return factory( $, root, root.document );
|
||||
};
|
||||
}
|
||||
else {
|
||||
// Browser
|
||||
factory( jQuery, window, document );
|
||||
}
|
||||
}(function( $, window, document, undefined ) {
|
||||
'use strict';
|
||||
var DataTable = $.fn.dataTable;
|
||||
|
||||
var factory = function( $, DataTable ) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Responsive is a plug-in for the DataTables library that makes use of
|
||||
@@ -64,7 +87,7 @@ var factory = function( $, DataTable ) {
|
||||
* @param {object} settings DataTables settings object for the host table
|
||||
* @param {object} [opts] Configuration options
|
||||
* @requires jQuery 1.7+
|
||||
* @requires DataTables 1.10.1+
|
||||
* @requires DataTables 1.10.3+
|
||||
*
|
||||
* @example
|
||||
* $('#example').DataTable( {
|
||||
@@ -74,13 +97,14 @@ var factory = function( $, DataTable ) {
|
||||
*/
|
||||
var Responsive = function ( settings, opts ) {
|
||||
// Sanity check that we are using DataTables 1.10 or newer
|
||||
if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.10.1' ) ) {
|
||||
throw 'DataTables Responsive requires DataTables 1.10.1 or newer';
|
||||
if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.10.3' ) ) {
|
||||
throw 'DataTables Responsive requires DataTables 1.10.3 or newer';
|
||||
}
|
||||
|
||||
this.s = {
|
||||
dt: new DataTable.Api( settings ),
|
||||
columns: []
|
||||
columns: [],
|
||||
current: []
|
||||
};
|
||||
|
||||
// Check if responsive has already been initialised on this table
|
||||
@@ -89,16 +113,23 @@ var Responsive = function ( settings, opts ) {
|
||||
}
|
||||
|
||||
// details is an object, but for simplicity the user can give it as a string
|
||||
// or a boolean
|
||||
if ( opts && typeof opts.details === 'string' ) {
|
||||
opts.details = { type: opts.details };
|
||||
}
|
||||
else if ( opts && opts.details === false ) {
|
||||
opts.details = { type: false };
|
||||
}
|
||||
else if ( opts && opts.details === true ) {
|
||||
opts.details = { type: 'inline' };
|
||||
}
|
||||
|
||||
this.c = $.extend( true, {}, Responsive.defaults, DataTable.defaults.responsive, opts );
|
||||
settings.responsive = this;
|
||||
this._constructor();
|
||||
};
|
||||
|
||||
Responsive.prototype = {
|
||||
$.extend( Responsive.prototype, {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Constructor
|
||||
*/
|
||||
@@ -112,17 +143,51 @@ Responsive.prototype = {
|
||||
{
|
||||
var that = this;
|
||||
var dt = this.s.dt;
|
||||
var dtPrivateSettings = dt.settings()[0];
|
||||
var oldWindowWidth = $(window).width();
|
||||
|
||||
dt.settings()[0]._responsive = this;
|
||||
|
||||
// Use DataTables' private throttle function to avoid processor thrashing
|
||||
$(window).on( 'resize.dtr orientationchange.dtr', dt.settings()[0].oApi._fnThrottle( function () {
|
||||
that._resize();
|
||||
// Use DataTables' throttle function to avoid processor thrashing on
|
||||
// resize
|
||||
$(window).on( 'resize.dtr orientationchange.dtr', DataTable.util.throttle( function () {
|
||||
// iOS has a bug whereby resize can fire when only scrolling
|
||||
// See: http://stackoverflow.com/questions/8898412
|
||||
var width = $(window).width();
|
||||
|
||||
if ( width !== oldWindowWidth ) {
|
||||
that._resize();
|
||||
oldWindowWidth = width;
|
||||
}
|
||||
} ) );
|
||||
|
||||
// DataTables doesn't currently trigger an event when a row is added, so
|
||||
// we need to hook into its private API to enforce the hidden rows when
|
||||
// new data is added
|
||||
dtPrivateSettings.oApi._fnCallbackReg( dtPrivateSettings, 'aoRowCreatedCallback', function (tr, data, idx) {
|
||||
if ( $.inArray( false, that.s.current ) !== -1 ) {
|
||||
$('td, th', tr).each( function ( i ) {
|
||||
var idx = dt.column.index( 'toData', i );
|
||||
|
||||
if ( that.s.current[idx] === false ) {
|
||||
$(this).css('display', 'none');
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
// Destroy event handler
|
||||
dt.on( 'destroy.dtr', function () {
|
||||
$(window).off( 'resize.dtr orientationchange.dtr draw.dtr' );
|
||||
dt.off( '.dtr' );
|
||||
$( dt.table().body() ).off( '.dtr' );
|
||||
$(window).off( 'resize.dtr orientationchange.dtr' );
|
||||
|
||||
// Restore the columns that we've hidden
|
||||
$.each( that.s.current, function ( i, val ) {
|
||||
if ( val === false ) {
|
||||
that._setColumnVis( i, true );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
// Reorder the breakpoints array here in case they have been added out
|
||||
@@ -132,40 +197,55 @@ Responsive.prototype = {
|
||||
a.width > b.width ? -1 : 0;
|
||||
} );
|
||||
|
||||
// Determine which columns are already hidden, and should therefore
|
||||
// remain hidden. todo - should this be done? See thread 22677
|
||||
//
|
||||
// this.s.alwaysHidden = dt.columns(':hidden').indexes();
|
||||
|
||||
this._classLogic();
|
||||
this._resizeAuto();
|
||||
|
||||
// Details handler
|
||||
var details = this.c.details;
|
||||
if ( details.type ) {
|
||||
that._detailsInit();
|
||||
this._detailsVis();
|
||||
|
||||
dt.on( 'column-visibility.dtr', function () {
|
||||
that._detailsVis();
|
||||
if ( details.type !== false ) {
|
||||
that._detailsInit();
|
||||
|
||||
// DataTables will trigger this event on every column it shows and
|
||||
// hides individually
|
||||
dt.on( 'column-visibility.dtr', function (e, ctx, col, vis) {
|
||||
that._classLogic();
|
||||
that._resizeAuto();
|
||||
that._resize();
|
||||
} );
|
||||
|
||||
// Redraw the details box on each draw. This is used until
|
||||
// DataTables implements a native `updated` event for rows
|
||||
// Redraw the details box on each draw which will happen if the data
|
||||
// has changed. This is used until DataTables implements a native
|
||||
// `updated` event for rows
|
||||
dt.on( 'draw.dtr', function () {
|
||||
dt.rows( {page: 'current'} ).iterator( 'row', function ( settings, idx ) {
|
||||
var row = dt.row( idx );
|
||||
|
||||
if ( row.child.isShown() ) {
|
||||
var info = that.c.details.renderer( dt, idx );
|
||||
row.child( info, 'child' ).show();
|
||||
}
|
||||
} );
|
||||
that._redrawChildren();
|
||||
} );
|
||||
|
||||
$(dt.table().node()).addClass( 'dtr-'+details.type );
|
||||
}
|
||||
|
||||
dt.on( 'column-reorder.dtr', function (e, settings, details) {
|
||||
that._classLogic();
|
||||
that._resizeAuto();
|
||||
that._resize();
|
||||
} );
|
||||
|
||||
// Change in column sizes means we need to calc
|
||||
dt.on( 'column-sizing.dtr', function () {
|
||||
that._resize();
|
||||
});
|
||||
|
||||
dt.on( 'init.dtr', function (e, settings, details) {
|
||||
that._resizeAuto();
|
||||
that._resize();
|
||||
|
||||
// If columns were hidden, then DataTables needs to adjust the
|
||||
// column sizing
|
||||
if ( $.inArray( false, that.s.current ) ) {
|
||||
dt.columns.adjust();
|
||||
}
|
||||
} );
|
||||
|
||||
// First pass - draw the table for the current viewport size
|
||||
this._resize();
|
||||
},
|
||||
@@ -193,6 +273,23 @@ Responsive.prototype = {
|
||||
var columns = this.s.columns;
|
||||
var i, ien;
|
||||
|
||||
// Create an array that defines the column ordering based first on the
|
||||
// column's priority, and secondly the column index. This allows the
|
||||
// columns to be removed from the right if the priority matches
|
||||
var order = columns
|
||||
.map( function ( col, idx ) {
|
||||
return {
|
||||
columnIdx: idx,
|
||||
priority: col.priority
|
||||
};
|
||||
} )
|
||||
.sort( function ( a, b ) {
|
||||
if ( a.priority !== b.priority ) {
|
||||
return a.priority - b.priority;
|
||||
}
|
||||
return a.columnIdx - b.columnIdx;
|
||||
} );
|
||||
|
||||
// Class logic - determine which columns are in this breakpoint based
|
||||
// on the classes. If no class control (i.e. `auto`) then `-` is used
|
||||
// to indicate this to the rest of the function
|
||||
@@ -234,23 +331,25 @@ Responsive.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
// Allow columns to be shown (counting from the left) until we run out
|
||||
// of room
|
||||
// Allow columns to be shown (counting by priority and then right to
|
||||
// left) until we run out of room
|
||||
var empty = false;
|
||||
for ( i=0, ien=display.length ; i<ien ; i++ ) {
|
||||
if ( display[i] === '-' && ! columns[i].control ) {
|
||||
for ( i=0, ien=order.length ; i<ien ; i++ ) {
|
||||
var colIdx = order[i].columnIdx;
|
||||
|
||||
if ( display[colIdx] === '-' && ! columns[colIdx].control && columns[colIdx].minWidth ) {
|
||||
// Once we've found a column that won't fit we don't let any
|
||||
// others display either, or columns might disappear in the
|
||||
// middle of the table
|
||||
if ( empty || usedWidth - columns[i].minWidth < 0 ) {
|
||||
if ( empty || usedWidth - columns[colIdx].minWidth < 0 ) {
|
||||
empty = true;
|
||||
display[i] = false;
|
||||
display[colIdx] = false;
|
||||
}
|
||||
else {
|
||||
display[i] = true;
|
||||
display[colIdx] = true;
|
||||
}
|
||||
|
||||
usedWidth -= columns[i].minWidth;
|
||||
usedWidth -= columns[colIdx].minWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,15 +396,27 @@ Responsive.prototype = {
|
||||
var that = this;
|
||||
var calc = {};
|
||||
var breakpoints = this.c.breakpoints;
|
||||
var columns = this.s.dt.columns().eq(0).map( function (i) {
|
||||
var className = this.column(i).header().className;
|
||||
var dt = this.s.dt;
|
||||
var columns = dt.columns().eq(0).map( function (i) {
|
||||
var column = this.column(i);
|
||||
var className = column.header().className;
|
||||
var priority = dt.settings()[0].aoColumns[i].responsivePriority;
|
||||
|
||||
if ( priority === undefined ) {
|
||||
var dataPriority = $(column.header()).data('priority');
|
||||
|
||||
priority = dataPriority !== undefined ?
|
||||
dataPriority * 1 :
|
||||
10000;
|
||||
}
|
||||
|
||||
return {
|
||||
className: className,
|
||||
includeIn: [],
|
||||
auto: false,
|
||||
control: false,
|
||||
never: className.match(/\bnever\b/) ? true : false
|
||||
never: className.match(/\bnever\b/) ? true : false,
|
||||
priority: priority
|
||||
};
|
||||
} );
|
||||
|
||||
@@ -346,8 +457,7 @@ Responsive.prototype = {
|
||||
}
|
||||
}
|
||||
else if ( operator === 'not-' ) {
|
||||
// Add all but this breakpoint (xxx need extra information)
|
||||
|
||||
// Add all but this breakpoint
|
||||
for ( i=0, ien=breakpoints.length ; i<ien ; i++ ) {
|
||||
if ( breakpoints[i].name.indexOf( matched ) === -1 ) {
|
||||
add( colIdx, breakpoints[i].name );
|
||||
@@ -374,7 +484,7 @@ Responsive.prototype = {
|
||||
} );
|
||||
return;
|
||||
}
|
||||
else if ( className === 'none' || className === 'never' ) {
|
||||
else if ( className === 'none' || col.never ) {
|
||||
// Include in none (default) and no auto
|
||||
hasClass = true;
|
||||
return;
|
||||
@@ -418,6 +528,33 @@ Responsive.prototype = {
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Show the details for the child row
|
||||
*
|
||||
* @param {DataTables.Api} row API instance for the row
|
||||
* @param {boolean} update Update flag
|
||||
* @private
|
||||
*/
|
||||
_detailsDisplay: function ( row, update )
|
||||
{
|
||||
var that = this;
|
||||
var dt = this.s.dt;
|
||||
var details = this.c.details;
|
||||
|
||||
if ( details && details.type ) {
|
||||
var res = details.display( row, update, function () {
|
||||
return details.renderer(
|
||||
dt, row[0], that._detailsObj(row[0])
|
||||
);
|
||||
} );
|
||||
|
||||
if ( res === true || res === false ) {
|
||||
$(dt.table().node()).triggerHandler( 'responsive-display.dt', [dt, row, res, update] );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Initialisation for the details handler
|
||||
*
|
||||
@@ -431,112 +568,105 @@ Responsive.prototype = {
|
||||
|
||||
// The inline type always uses the first child as the target
|
||||
if ( details.type === 'inline' ) {
|
||||
details.target = 'td:first-child';
|
||||
details.target = 'td:first-child, th:first-child';
|
||||
}
|
||||
|
||||
// Keyboard accessibility
|
||||
dt.on( 'draw.dtr', function () {
|
||||
that._tabIndexes();
|
||||
} );
|
||||
that._tabIndexes(); // Initial draw has already happened
|
||||
|
||||
$( dt.table().body() ).on( 'keyup.dtr', 'td, th', function (e) {
|
||||
if ( e.keyCode === 13 && $(this).data('dtr-keyboard') ) {
|
||||
$(this).click();
|
||||
}
|
||||
} );
|
||||
|
||||
// type.target can be a string jQuery selector or a column index
|
||||
var target = details.target;
|
||||
var selector = typeof target === 'string' ? target : 'td';
|
||||
var selector = typeof target === 'string' ? target : 'td, th';
|
||||
|
||||
// Click handler to show / hide the details rows when they are available
|
||||
$( dt.table().body() ).on( 'click', selector, function (e) {
|
||||
// If the table is not collapsed (i.e. there is no hidden columns)
|
||||
// then take no action
|
||||
if ( ! $(dt.table().node()).hasClass('collapsed' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that the row is actually a DataTable's controlled node
|
||||
if ( ! dt.row( $(this).closest('tr') ).length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// For column index, we determine if we should act or not in the
|
||||
// handler - otherwise it is already okay
|
||||
if ( typeof target === 'number' ) {
|
||||
var targetIdx = target < 0 ?
|
||||
dt.columns().eq(0).length + target :
|
||||
target;
|
||||
|
||||
if ( dt.cell( this ).index().column !== targetIdx ) {
|
||||
$( dt.table().body() )
|
||||
.on( 'click.dtr mousedown.dtr mouseup.dtr', selector, function (e) {
|
||||
// If the table is not collapsed (i.e. there is no hidden columns)
|
||||
// then take no action
|
||||
if ( ! $(dt.table().node()).hasClass('collapsed' ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// $().closest() includes itself in its check
|
||||
var row = dt.row( $(this).closest('tr') );
|
||||
// Check that the row is actually a DataTable's controlled node
|
||||
if ( ! dt.row( $(this).closest('tr') ).length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( row.child.isShown() ) {
|
||||
row.child( false );
|
||||
$( row.node() ).removeClass( 'parent' );
|
||||
}
|
||||
else {
|
||||
var info = that.c.details.renderer( dt, row[0] );
|
||||
row.child( info, 'child' ).show();
|
||||
$( row.node() ).addClass( 'parent' );
|
||||
}
|
||||
} );
|
||||
// For column index, we determine if we should act or not in the
|
||||
// handler - otherwise it is already okay
|
||||
if ( typeof target === 'number' ) {
|
||||
var targetIdx = target < 0 ?
|
||||
dt.columns().eq(0).length + target :
|
||||
target;
|
||||
|
||||
if ( dt.cell( this ).index().column !== targetIdx ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// $().closest() includes itself in its check
|
||||
var row = dt.row( $(this).closest('tr') );
|
||||
|
||||
// Check event type to do an action
|
||||
if ( e.type === 'click' ) {
|
||||
// The renderer is given as a function so the caller can execute it
|
||||
// only when they need (i.e. if hiding there is no point is running
|
||||
// the renderer)
|
||||
that._detailsDisplay( row, false );
|
||||
}
|
||||
else if ( e.type === 'mousedown' ) {
|
||||
// For mouse users, prevent the focus ring from showing
|
||||
$(this).css('outline', 'none');
|
||||
}
|
||||
else if ( e.type === 'mouseup' ) {
|
||||
// And then re-allow at the end of the click
|
||||
$(this).blur().css('outline', '');
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Update the child rows in the table whenever the column visibility changes
|
||||
*
|
||||
* Get the details to pass to a renderer for a row
|
||||
* @param {int} rowIdx Row index
|
||||
* @private
|
||||
*/
|
||||
_detailsVis: function ()
|
||||
_detailsObj: function ( rowIdx )
|
||||
{
|
||||
var that = this;
|
||||
var dt = this.s.dt;
|
||||
|
||||
// Find how many columns are hidden
|
||||
var hiddenColumns = dt.columns().indexes().filter( function ( idx ) {
|
||||
var col = dt.column( idx );
|
||||
|
||||
if ( col.visible() ) {
|
||||
return null;
|
||||
return $.map( this.s.columns, function( col, i ) {
|
||||
if ( col.never ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only counts as hidden if it doesn't have the `never` class
|
||||
return $( col.header() ).hasClass( 'never' ) ? null : idx;
|
||||
return {
|
||||
title: dt.settings()[0].aoColumns[ i ].sTitle,
|
||||
data: dt.cell( rowIdx, i ).render( that.c.orthogonal ),
|
||||
hidden: dt.column( i ).visible() && !that.s.current[ i ],
|
||||
columnIndex: i,
|
||||
rowIndex: rowIdx
|
||||
};
|
||||
} );
|
||||
var haveHidden = true;
|
||||
|
||||
if ( hiddenColumns.length === 0 || ( hiddenColumns.length === 1 && this.s.columns[ hiddenColumns[0] ].control ) ) {
|
||||
haveHidden = false;
|
||||
}
|
||||
|
||||
if ( haveHidden ) {
|
||||
// Show all existing child rows
|
||||
dt.rows( { page: 'current' } ).eq(0).each( function (idx) {
|
||||
var row = dt.row( idx );
|
||||
|
||||
if ( row.child() ) {
|
||||
var info = that.c.details.renderer( dt, row[0] );
|
||||
|
||||
// The renderer can return false to have no child row
|
||||
if ( info === false ) {
|
||||
row.child.hide();
|
||||
}
|
||||
else {
|
||||
row.child( info, 'child' ).show();
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
else {
|
||||
// Hide all existing child rows
|
||||
dt.rows( { page: 'current' } ).eq(0).each( function (idx) {
|
||||
dt.row( idx ).child.hide();
|
||||
} );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Find a breakpoint object from a name
|
||||
*
|
||||
* @param {string} name Breakpoint name to find
|
||||
* @return {object} Breakpoint description object
|
||||
* @private
|
||||
*/
|
||||
_find: function ( name )
|
||||
{
|
||||
@@ -550,6 +680,25 @@ Responsive.prototype = {
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Re-create the contents of the child rows as the display has changed in
|
||||
* some way.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_redrawChildren: function ()
|
||||
{
|
||||
var that = this;
|
||||
var dt = this.s.dt;
|
||||
|
||||
dt.rows( {page: 'current'} ).iterator( 'row', function ( settings, idx ) {
|
||||
var row = dt.row( idx );
|
||||
|
||||
that._detailsDisplay( dt.row( idx ), true );
|
||||
} );
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Alter the table display for a resized viewport. This involves first
|
||||
* determining what breakpoint the window currently is in, getting the
|
||||
@@ -559,12 +708,14 @@ Responsive.prototype = {
|
||||
*/
|
||||
_resize: function ()
|
||||
{
|
||||
var that = this;
|
||||
var dt = this.s.dt;
|
||||
var width = $(window).width();
|
||||
var breakpoints = this.c.breakpoints;
|
||||
var breakpoint = breakpoints[0].name;
|
||||
var columns = this.s.columns;
|
||||
var i, ien;
|
||||
var oldVis = this.s.current.slice();
|
||||
|
||||
// Determine what breakpoint we are currently at
|
||||
for ( i=breakpoints.length-1 ; i>=0 ; i-- ) {
|
||||
@@ -576,23 +727,36 @@ Responsive.prototype = {
|
||||
|
||||
// Show the columns for that break point
|
||||
var columnsVis = this._columnsVisiblity( breakpoint );
|
||||
this.s.current = columnsVis;
|
||||
|
||||
// Set the class before the column visibility is changed so event
|
||||
// listeners know what the state is. Need to determine if there are
|
||||
// any columns that are not visible but can be shown
|
||||
var collapsedClass = false;
|
||||
for ( i=0, ien=columns.length ; i<ien ; i++ ) {
|
||||
if ( columnsVis[i] === false && ! columns[i].never ) {
|
||||
if ( columnsVis[i] === false && ! columns[i].never && ! columns[i].control ) {
|
||||
collapsedClass = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$( dt.table().node() ).toggleClass('collapsed', collapsedClass );
|
||||
$( dt.table().node() ).toggleClass( 'collapsed', collapsedClass );
|
||||
|
||||
var changed = false;
|
||||
|
||||
dt.columns().eq(0).each( function ( colIdx, i ) {
|
||||
dt.column( colIdx ).visible( columnsVis[i] );
|
||||
if ( columnsVis[i] !== oldVis[i] ) {
|
||||
changed = true;
|
||||
that._setColumnVis( colIdx, columnsVis[i] );
|
||||
}
|
||||
} );
|
||||
|
||||
if ( changed ) {
|
||||
this._redrawChildren();
|
||||
|
||||
// Inform listeners of the change
|
||||
$(dt.table().node()).trigger( 'responsive-resize.dt', [dt, this.s.current] );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -625,25 +789,44 @@ Responsive.prototype = {
|
||||
var columnWidths = dt.columns;
|
||||
var clonedTable = dt.table().node().cloneNode( false );
|
||||
var clonedHeader = $( dt.table().header().cloneNode( false ) ).appendTo( clonedTable );
|
||||
var clonedBody = $( dt.table().body().cloneNode( false ) ).appendTo( clonedTable );
|
||||
var clonedBody = $( dt.table().body() ).clone( false, false ).empty().appendTo( clonedTable ); // use jQuery because of IE8
|
||||
|
||||
$( dt.table().footer() ).clone( false ).appendTo( clonedTable );
|
||||
// Header
|
||||
var headerCells = dt.columns()
|
||||
.header()
|
||||
.filter( function (idx) {
|
||||
return dt.column(idx).visible();
|
||||
} )
|
||||
.to$()
|
||||
.clone( false )
|
||||
.css( 'display', 'table-cell' );
|
||||
|
||||
// This is a bit slow, but we need to get a clone of each row that
|
||||
// includes all columns. As such, try to do this as little as possible.
|
||||
dt.rows( { page: 'current' } ).indexes().flatten().each( function ( idx ) {
|
||||
var clone = dt.row( idx ).node().cloneNode( true );
|
||||
|
||||
if ( dt.columns( ':hidden' ).flatten().length ) {
|
||||
$(clone).append( dt.cells( idx, ':hidden' ).nodes().to$().clone() );
|
||||
}
|
||||
// Body rows - we don't need to take account of DataTables' column
|
||||
// visibility since we implement our own here (hence the `display` set)
|
||||
$(clonedBody)
|
||||
.append( $(dt.rows( { page: 'current' } ).nodes()).clone( false ) )
|
||||
.find( 'th, td' ).css( 'display', '' );
|
||||
|
||||
$(clone).appendTo( clonedBody );
|
||||
} );
|
||||
// Footer
|
||||
var footer = dt.table().footer();
|
||||
if ( footer ) {
|
||||
var clonedFooter = $( footer.cloneNode( false ) ).appendTo( clonedTable );
|
||||
var footerCells = dt.columns()
|
||||
.header()
|
||||
.filter( function (idx) {
|
||||
return dt.column(idx).visible();
|
||||
} )
|
||||
.to$()
|
||||
.clone( false )
|
||||
.css( 'display', 'table-cell' );
|
||||
|
||||
$('<tr/>')
|
||||
.append( footerCells )
|
||||
.appendTo( clonedFooter );
|
||||
}
|
||||
|
||||
var cells = dt.columns().header().to$().clone( false );
|
||||
$('<tr/>')
|
||||
.append( cells )
|
||||
.append( headerCells )
|
||||
.appendTo( clonedHeader );
|
||||
|
||||
// In the inline case extra padding is applied to the first column to
|
||||
@@ -661,19 +844,67 @@ Responsive.prototype = {
|
||||
} )
|
||||
.append( clonedTable );
|
||||
|
||||
// Remove columns which are not to be included
|
||||
inserted.find('th.never, td.never').remove();
|
||||
|
||||
inserted.insertBefore( dt.table().node() );
|
||||
|
||||
// The cloned header now contains the smallest that each column can be
|
||||
dt.columns().eq(0).each( function ( idx ) {
|
||||
columns[idx].minWidth = cells[ idx ].offsetWidth || 0;
|
||||
headerCells.each( function (i) {
|
||||
var idx = dt.column.index( 'fromVisible', i );
|
||||
columns[ idx ].minWidth = this.offsetWidth || 0;
|
||||
} );
|
||||
|
||||
inserted.remove();
|
||||
},
|
||||
|
||||
/**
|
||||
* Set a column's visibility.
|
||||
*
|
||||
* We don't use DataTables' column visibility controls in order to ensure
|
||||
* that column visibility can Responsive can no-exist. Since only IE8+ is
|
||||
* supported (and all evergreen browsers of course) the control of the
|
||||
* display attribute works well.
|
||||
*
|
||||
* @param {integer} col Column index
|
||||
* @param {boolean} showHide Show or hide (true or false)
|
||||
* @private
|
||||
*/
|
||||
_setColumnVis: function ( col, showHide )
|
||||
{
|
||||
var dt = this.s.dt;
|
||||
var display = showHide ? '' : 'none'; // empty string will remove the attr
|
||||
|
||||
$( dt.column( col ).header() ).css( 'display', display );
|
||||
$( dt.column( col ).footer() ).css( 'display', display );
|
||||
dt.column( col ).nodes().to$().css( 'display', display );
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Update the cell tab indexes for keyboard accessibility. This is called on
|
||||
* every table draw - that is potentially inefficient, but also the least
|
||||
* complex option given that column visibility can change on the fly. Its a
|
||||
* shame user-focus was removed from CSS 3 UI, as it would have solved this
|
||||
* issue with a single CSS statement.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_tabIndexes: function ()
|
||||
{
|
||||
var dt = this.s.dt;
|
||||
var cells = dt.cells( { page: 'current' } ).nodes().to$();
|
||||
var ctx = dt.settings()[0];
|
||||
var target = this.c.details.target;
|
||||
|
||||
cells.filter( '[data-dtr-keyboard]' ).removeData( '[data-dtr-keyboard]' );
|
||||
|
||||
var selector = typeof target === 'number' ?
|
||||
':eq('+target+')' :
|
||||
target;
|
||||
|
||||
$( selector, dt.rows( { page: 'current' } ).nodes() )
|
||||
.attr( 'tabIndex', ctx.iTabIndex )
|
||||
.data( 'dtr-keyboard', 1 );
|
||||
}
|
||||
};
|
||||
} );
|
||||
|
||||
|
||||
/**
|
||||
@@ -695,6 +926,110 @@ Responsive.breakpoints = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Display methods - functions which define how the hidden data should be shown
|
||||
* in the table.
|
||||
*
|
||||
* @namespace
|
||||
* @name Responsive.defaults
|
||||
* @static
|
||||
*/
|
||||
Responsive.display = {
|
||||
childRow: function ( row, update, render ) {
|
||||
if ( update ) {
|
||||
if ( $(row.node()).hasClass('parent') ) {
|
||||
row.child( render(), 'child' ).show();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( ! row.child.isShown() ) {
|
||||
row.child( render(), 'child' ).show();
|
||||
$( row.node() ).addClass( 'parent' );
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
row.child( false );
|
||||
$( row.node() ).removeClass( 'parent' );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
childRowImmediate: function ( row, update, render ) {
|
||||
if ( (! update && row.child.isShown()) || ! row.responsive.hasHidden() ) {
|
||||
// User interaction and the row is show, or nothing to show
|
||||
row.child( false );
|
||||
$( row.node() ).removeClass( 'parent' );
|
||||
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
// Display
|
||||
row.child( render(), 'child' ).show();
|
||||
$( row.node() ).addClass( 'parent' );
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
// This is a wrapper so the modal options for Bootstrap and jQuery UI can
|
||||
// have options passed into them. This specific one doesn't need to be a
|
||||
// function but it is for consistency in the `modal` name
|
||||
modal: function ( options ) {
|
||||
return function ( row, update, render ) {
|
||||
if ( ! update ) {
|
||||
// Show a modal
|
||||
var close = function () {
|
||||
modal.remove(); // will tidy events for us
|
||||
$(document).off( 'keypress.dtr' );
|
||||
};
|
||||
|
||||
var modal = $('<div class="dtr-modal"/>')
|
||||
.append( $('<div class="dtr-modal-display"/>')
|
||||
.append( $('<div class="dtr-modal-content"/>')
|
||||
.append( render() )
|
||||
)
|
||||
.append( $('<div class="dtr-modal-close">×</div>' )
|
||||
.click( function () {
|
||||
close();
|
||||
} )
|
||||
)
|
||||
)
|
||||
.append( $('<div class="dtr-modal-background"/>')
|
||||
.click( function () {
|
||||
close();
|
||||
} )
|
||||
)
|
||||
.appendTo( 'body' );
|
||||
|
||||
$(document).on( 'keyup.dtr', function (e) {
|
||||
if ( e.keyCode === 27 ) {
|
||||
e.stopPropagation();
|
||||
|
||||
close();
|
||||
}
|
||||
} );
|
||||
}
|
||||
else {
|
||||
$('div.dtr-modal-content')
|
||||
.empty()
|
||||
.append( render() );
|
||||
}
|
||||
|
||||
if ( options && options.header ) {
|
||||
$('div.dtr-modal-content').prepend(
|
||||
'<h2>'+options.header( row )+'</h2>'
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Responsive default settings for initialisation
|
||||
*
|
||||
@@ -730,6 +1065,7 @@ Responsive.defaults = {
|
||||
*
|
||||
* The object consists of the following properties:
|
||||
*
|
||||
* * `display` - A function that is used to show and hide the hidden details
|
||||
* * `renderer` - function that is called for display of the child row data.
|
||||
* The default function will show the data from the hidden columns
|
||||
* * `target` - Used as the selector for what objects to attach the child
|
||||
@@ -740,36 +1076,21 @@ Responsive.defaults = {
|
||||
* @type {Object|string}
|
||||
*/
|
||||
details: {
|
||||
renderer: function ( api, rowIdx ) {
|
||||
var data = api.cells( rowIdx, ':hidden' ).eq(0).map( function ( cell ) {
|
||||
var header = $( api.column( cell.column ).header() );
|
||||
var idx = api.cell( cell ).index();
|
||||
display: Responsive.display.childRow,
|
||||
|
||||
if ( header.hasClass( 'control' ) || header.hasClass( 'never' ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Use a non-public DT API method to render the data for display
|
||||
// This needs to be updated when DT adds a suitable method for
|
||||
// this type of data retrieval
|
||||
var dtPrivate = api.settings()[0];
|
||||
var cellData = dtPrivate.oApi._fnGetCellData(
|
||||
dtPrivate, idx.row, idx.column, 'display'
|
||||
);
|
||||
var title = header.text();
|
||||
if ( title ) {
|
||||
title = title + ':';
|
||||
}
|
||||
|
||||
return '<li data-dtr-index="'+idx.column+'">'+
|
||||
renderer: function ( api, rowIdx, columns ) {
|
||||
var data = $.map( columns, function ( col, i ) {
|
||||
return col.hidden ?
|
||||
'<li data-dtr-index="'+col.columnIndex+'" data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+
|
||||
'<span class="dtr-title">'+
|
||||
title+
|
||||
col.title+
|
||||
'</span> '+
|
||||
'<span class="dtr-data">'+
|
||||
cellData+
|
||||
col.data+
|
||||
'</span>'+
|
||||
'</li>';
|
||||
} ).toArray().join('');
|
||||
'</li>' :
|
||||
'';
|
||||
} ).join('');
|
||||
|
||||
return data ?
|
||||
$('<ul data-dtr-index="'+rowIdx+'"/>').append( data ) :
|
||||
@@ -779,7 +1100,15 @@ Responsive.defaults = {
|
||||
target: 0,
|
||||
|
||||
type: 'inline'
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Orthogonal data request option. This is used to define the data type
|
||||
* requested when Responsive gets the data to show in the child row.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
orthogonal: 'display'
|
||||
};
|
||||
|
||||
|
||||
@@ -819,6 +1148,14 @@ Api.register( 'responsive.recalc()', function () {
|
||||
} );
|
||||
} );
|
||||
|
||||
Api.register( 'responsive.hasHidden()', function () {
|
||||
var ctx = this.context[0];
|
||||
|
||||
return ctx._responsive ?
|
||||
$.inArray( false, ctx._responsive.s.current ) !== -1 :
|
||||
false;
|
||||
} );
|
||||
|
||||
|
||||
/**
|
||||
* Version information
|
||||
@@ -826,7 +1163,7 @@ Api.register( 'responsive.recalc()', function () {
|
||||
* @name Responsive.version
|
||||
* @static
|
||||
*/
|
||||
Responsive.version = '1.0.6';
|
||||
Responsive.version = '2.0.2';
|
||||
|
||||
|
||||
$.fn.dataTable.Responsive = Responsive;
|
||||
@@ -834,7 +1171,7 @@ $.fn.DataTable.Responsive = Responsive;
|
||||
|
||||
// Attach a listener to the document which listens for DataTables initialisation
|
||||
// events so we can automatically initialise
|
||||
$(document).on( 'init.dt.dtr', function (e, settings, json) {
|
||||
$(document).on( 'preInit.dt.dtr', function (e, settings, json) {
|
||||
if ( e.namespace !== 'dt' ) {
|
||||
return;
|
||||
}
|
||||
@@ -852,22 +1189,6 @@ $(document).on( 'init.dt.dtr', function (e, settings, json) {
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
return Responsive;
|
||||
}; // /factory
|
||||
|
||||
|
||||
// Define as an AMD module if possible
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
define( ['jquery', 'datatables'], factory );
|
||||
}
|
||||
else if ( typeof exports === 'object' ) {
|
||||
// Node/CommonJS
|
||||
factory( require('jquery'), require('datatables') );
|
||||
}
|
||||
else if ( jQuery && !jQuery.fn.dataTable.Responsive ) {
|
||||
// Otherwise simply initialise as normal, stopping multiple evaluation
|
||||
factory( jQuery, jQuery.fn.dataTable );
|
||||
}
|
||||
|
||||
|
||||
})(window, document);
|
||||
}));
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
/*!
|
||||
Responsive 1.0.6
|
||||
2014-2015 SpryMedia Ltd - datatables.net/license
|
||||
Responsive 2.0.2
|
||||
2014-2016 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
(function(n,p){var o=function(e,k){var h=function(d,a){if(!k.versionCheck||!k.versionCheck("1.10.1"))throw"DataTables Responsive requires DataTables 1.10.1 or newer";this.s={dt:new k.Api(d),columns:[]};this.s.dt.settings()[0].responsive||(a&&"string"===typeof a.details&&(a.details={type:a.details}),this.c=e.extend(!0,{},h.defaults,k.defaults.responsive,a),d.responsive=this,this._constructor())};h.prototype={_constructor:function(){var d=this,a=this.s.dt;a.settings()[0]._responsive=this;e(n).on("resize.dtr orientationchange.dtr",
|
||||
a.settings()[0].oApi._fnThrottle(function(){d._resize()}));a.on("destroy.dtr",function(){e(n).off("resize.dtr orientationchange.dtr draw.dtr")});this.c.breakpoints.sort(function(a,c){return a.width<c.width?1:a.width>c.width?-1:0});this._classLogic();this._resizeAuto();var c=this.c.details;c.type&&(d._detailsInit(),this._detailsVis(),a.on("column-visibility.dtr",function(){d._detailsVis()}),a.on("draw.dtr",function(){a.rows({page:"current"}).iterator("row",function(b,c){var f=a.row(c);if(f.child.isShown()){var i=
|
||||
d.c.details.renderer(a,c);f.child(i,"child").show()}})}),e(a.table().node()).addClass("dtr-"+c.type));this._resize()},_columnsVisiblity:function(d){var a=this.s.dt,c=this.s.columns,b,g,f=e.map(c,function(a){return a.auto&&null===a.minWidth?!1:!0===a.auto?"-":-1!==e.inArray(d,a.includeIn)}),i=0;b=0;for(g=f.length;b<g;b++)!0===f[b]&&(i+=c[b].minWidth);b=a.settings()[0].oScroll;b=b.sY||b.sX?b.iBarWidth:0;a=a.table().container().offsetWidth-b-i;b=0;for(g=f.length;b<g;b++)c[b].control&&(a-=c[b].minWidth);
|
||||
i=!1;b=0;for(g=f.length;b<g;b++)"-"===f[b]&&!c[b].control&&(i||0>a-c[b].minWidth?(i=!0,f[b]=!1):f[b]=!0,a-=c[b].minWidth);a=!1;b=0;for(g=c.length;b<g;b++)if(!c[b].control&&!c[b].never&&!f[b]){a=!0;break}b=0;for(g=c.length;b<g;b++)c[b].control&&(f[b]=a);-1===e.inArray(!0,f)&&(f[0]=!0);return f},_classLogic:function(){var d=this,a=this.c.breakpoints,c=this.s.dt.columns().eq(0).map(function(a){a=this.column(a).header().className;return{className:a,includeIn:[],auto:!1,control:!1,never:a.match(/\bnever\b/)?
|
||||
!0:!1}}),b=function(a,b){var d=c[a].includeIn;-1===e.inArray(b,d)&&d.push(b)},g=function(f,g,e,j){if(e)if("max-"===e){j=d._find(g).width;g=0;for(e=a.length;g<e;g++)a[g].width<=j&&b(f,a[g].name)}else if("min-"===e){j=d._find(g).width;g=0;for(e=a.length;g<e;g++)a[g].width>=j&&b(f,a[g].name)}else{if("not-"===e){g=0;for(e=a.length;g<e;g++)-1===a[g].name.indexOf(j)&&b(f,a[g].name)}}else c[f].includeIn.push(g)};c.each(function(b,c){for(var d=b.className.split(" "),j=!1,h=0,k=d.length;h<k;h++){var l=e.trim(d[h]);
|
||||
if("all"===l){j=!0;b.includeIn=e.map(a,function(a){return a.name});return}if("none"===l||"never"===l){j=!0;return}if("control"===l){j=!0;b.control=!0;return}e.each(a,function(a,b){var d=b.name.split("-"),e=l.match(RegExp("(min\\-|max\\-|not\\-)?("+d[0]+")(\\-[_a-zA-Z0-9])?"));e&&(j=!0,e[2]===d[0]&&e[3]==="-"+d[1]?g(c,b.name,e[1],e[2]+e[3]):e[2]===d[0]&&!e[3]&&g(c,b.name,e[1],e[2]))})}j||(b.auto=!0)});this.s.columns=c},_detailsInit:function(){var d=this,a=this.s.dt,c=this.c.details;"inline"===c.type&&
|
||||
(c.target="td:first-child");var b=c.target;e(a.table().body()).on("click","string"===typeof b?b:"td",function(){if(e(a.table().node()).hasClass("collapsed")&&a.row(e(this).closest("tr")).length){if(typeof b==="number"){var c=b<0?a.columns().eq(0).length+b:b;if(a.cell(this).index().column!==c)return}c=a.row(e(this).closest("tr"));if(c.child.isShown()){c.child(false);e(c.node()).removeClass("parent")}else{var f=d.c.details.renderer(a,c[0]);c.child(f,"child").show();e(c.node()).addClass("parent")}}})},
|
||||
_detailsVis:function(){var d=this,a=this.s.dt,c=a.columns().indexes().filter(function(b){var c=a.column(b);return c.visible()?null:e(c.header()).hasClass("never")?null:b}),b=!0;if(0===c.length||1===c.length&&this.s.columns[c[0]].control)b=!1;b?a.rows({page:"current"}).eq(0).each(function(b){b=a.row(b);if(b.child()){var c=d.c.details.renderer(a,b[0]);!1===c?b.child.hide():b.child(c,"child").show()}}):a.rows({page:"current"}).eq(0).each(function(b){a.row(b).child.hide()})},_find:function(d){for(var a=
|
||||
this.c.breakpoints,c=0,b=a.length;c<b;c++)if(a[c].name===d)return a[c]},_resize:function(){var d=this.s.dt,a=e(n).width(),c=this.c.breakpoints,b=c[0].name,g=this.s.columns,f;for(f=c.length-1;0<=f;f--)if(a<=c[f].width){b=c[f].name;break}var i=this._columnsVisiblity(b),c=!1;f=0;for(a=g.length;f<a;f++)if(!1===i[f]&&!g[f].never){c=!0;break}e(d.table().node()).toggleClass("collapsed",c);d.columns().eq(0).each(function(a,b){d.column(a).visible(i[b])})},_resizeAuto:function(){var d=this.s.dt,a=this.s.columns;
|
||||
if(this.c.auto&&-1!==e.inArray(!0,e.map(a,function(a){return a.auto}))){d.table().node();var c=d.table().node().cloneNode(!1),b=e(d.table().header().cloneNode(!1)).appendTo(c),g=e(d.table().body().cloneNode(!1)).appendTo(c);e(d.table().footer()).clone(!1).appendTo(c);d.rows({page:"current"}).indexes().flatten().each(function(a){var b=d.row(a).node().cloneNode(!0);d.columns(":hidden").flatten().length&&e(b).append(d.cells(a,":hidden").nodes().to$().clone());e(b).appendTo(g)});var f=d.columns().header().to$().clone(!1);
|
||||
e("<tr/>").append(f).appendTo(b);"inline"===this.c.details.type&&e(c).addClass("dtr-inline collapsed");c=e("<div/>").css({width:1,height:1,overflow:"hidden"}).append(c);c.find("th.never, td.never").remove();c.insertBefore(d.table().node());d.columns().eq(0).each(function(b){a[b].minWidth=f[b].offsetWidth||0});c.remove()}}};h.breakpoints=[{name:"desktop",width:Infinity},{name:"tablet-l",width:1024},{name:"tablet-p",width:768},{name:"mobile-l",width:480},{name:"mobile-p",width:320}];h.defaults={breakpoints:h.breakpoints,
|
||||
auto:!0,details:{renderer:function(d,a){var c=d.cells(a,":hidden").eq(0).map(function(a){var c=e(d.column(a.column).header()),a=d.cell(a).index();if(c.hasClass("control")||c.hasClass("never"))return"";var f=d.settings()[0],f=f.oApi._fnGetCellData(f,a.row,a.column,"display");(c=c.text())&&(c+=":");return'<li data-dtr-index="'+a.column+'"><span class="dtr-title">'+c+'</span> <span class="dtr-data">'+f+"</span></li>"}).toArray().join("");return c?e('<ul data-dtr-index="'+a+'"/>').append(c):!1},target:0,
|
||||
type:"inline"}};var m=e.fn.dataTable.Api;m.register("responsive()",function(){return this});m.register("responsive.index()",function(d){d=e(d);return{column:d.data("dtr-index"),row:d.parent().data("dtr-index")}});m.register("responsive.rebuild()",function(){return this.iterator("table",function(d){d._responsive&&d._responsive._classLogic()})});m.register("responsive.recalc()",function(){return this.iterator("table",function(d){d._responsive&&(d._responsive._resizeAuto(),d._responsive._resize())})});
|
||||
h.version="1.0.6";e.fn.dataTable.Responsive=h;e.fn.DataTable.Responsive=h;e(p).on("init.dt.dtr",function(d,a){if("dt"===d.namespace&&(e(a.nTable).hasClass("responsive")||e(a.nTable).hasClass("dt-responsive")||a.oInit.responsive||k.defaults.responsive)){var c=a.oInit.responsive;!1!==c&&new h(a,e.isPlainObject(c)?c:{})}});return h};"function"===typeof define&&define.amd?define(["jquery","datatables"],o):"object"===typeof exports?o(require("jquery"),require("datatables")):jQuery&&!jQuery.fn.dataTable.Responsive&&
|
||||
o(jQuery,jQuery.fn.dataTable)})(window,document);
|
||||
(function(c){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(j){return c(j,window,document)}):"object"===typeof exports?module.exports=function(j,k){j||(j=window);if(!k||!k.fn.dataTable)k=require("datatables.net")(j,k).$;return c(k,j,j.document)}:c(jQuery,window,document)})(function(c,j,k,p){var n=c.fn.dataTable,l=function(a,b){if(!n.versionCheck||!n.versionCheck("1.10.3"))throw"DataTables Responsive requires DataTables 1.10.3 or newer";this.s={dt:new n.Api(a),columns:[],
|
||||
current:[]};this.s.dt.settings()[0].responsive||(b&&"string"===typeof b.details?b.details={type:b.details}:b&&!1===b.details?b.details={type:!1}:b&&!0===b.details&&(b.details={type:"inline"}),this.c=c.extend(!0,{},l.defaults,n.defaults.responsive,b),a.responsive=this,this._constructor())};c.extend(l.prototype,{_constructor:function(){var a=this,b=this.s.dt,d=b.settings()[0],e=c(j).width();b.settings()[0]._responsive=this;c(j).on("resize.dtr orientationchange.dtr",n.util.throttle(function(){var b=
|
||||
c(j).width();b!==e&&(a._resize(),e=b)}));d.oApi._fnCallbackReg(d,"aoRowCreatedCallback",function(e){-1!==c.inArray(!1,a.s.current)&&c("td, th",e).each(function(e){e=b.column.index("toData",e);!1===a.s.current[e]&&c(this).css("display","none")})});b.on("destroy.dtr",function(){b.off(".dtr");c(b.table().body()).off(".dtr");c(j).off("resize.dtr orientationchange.dtr");c.each(a.s.current,function(b,e){!1===e&&a._setColumnVis(b,!0)})});this.c.breakpoints.sort(function(a,b){return a.width<b.width?1:a.width>
|
||||
b.width?-1:0});this._classLogic();this._resizeAuto();d=this.c.details;!1!==d.type&&(a._detailsInit(),b.on("column-visibility.dtr",function(){a._classLogic();a._resizeAuto();a._resize()}),b.on("draw.dtr",function(){a._redrawChildren()}),c(b.table().node()).addClass("dtr-"+d.type));b.on("column-reorder.dtr",function(){a._classLogic();a._resizeAuto();a._resize()});b.on("column-sizing.dtr",function(){a._resize()});b.on("init.dtr",function(){a._resizeAuto();a._resize();c.inArray(false,a.s.current)&&b.columns.adjust()});
|
||||
this._resize()},_columnsVisiblity:function(a){var b=this.s.dt,d=this.s.columns,e,f,g=d.map(function(a,b){return{columnIdx:b,priority:a.priority}}).sort(function(a,b){return a.priority!==b.priority?a.priority-b.priority:a.columnIdx-b.columnIdx}),h=c.map(d,function(b){return b.auto&&null===b.minWidth?!1:!0===b.auto?"-":-1!==c.inArray(a,b.includeIn)}),m=0;e=0;for(f=h.length;e<f;e++)!0===h[e]&&(m+=d[e].minWidth);e=b.settings()[0].oScroll;e=e.sY||e.sX?e.iBarWidth:0;b=b.table().container().offsetWidth-
|
||||
e-m;e=0;for(f=h.length;e<f;e++)d[e].control&&(b-=d[e].minWidth);m=!1;e=0;for(f=g.length;e<f;e++){var i=g[e].columnIdx;"-"===h[i]&&(!d[i].control&&d[i].minWidth)&&(m||0>b-d[i].minWidth?(m=!0,h[i]=!1):h[i]=!0,b-=d[i].minWidth)}g=!1;e=0;for(f=d.length;e<f;e++)if(!d[e].control&&!d[e].never&&!h[e]){g=!0;break}e=0;for(f=d.length;e<f;e++)d[e].control&&(h[e]=g);-1===c.inArray(!0,h)&&(h[0]=!0);return h},_classLogic:function(){var a=this,b=this.c.breakpoints,d=this.s.dt,e=d.columns().eq(0).map(function(b){var a=
|
||||
this.column(b),e=a.header().className,b=d.settings()[0].aoColumns[b].responsivePriority;b===p&&(a=c(a.header()).data("priority"),b=a!==p?1*a:1E4);return{className:e,includeIn:[],auto:!1,control:!1,never:e.match(/\bnever\b/)?!0:!1,priority:b}}),f=function(b,a){var d=e[b].includeIn;-1===c.inArray(a,d)&&d.push(a)},g=function(c,d,i,g){if(i)if("max-"===i){g=a._find(d).width;d=0;for(i=b.length;d<i;d++)b[d].width<=g&&f(c,b[d].name)}else if("min-"===i){g=a._find(d).width;d=0;for(i=b.length;d<i;d++)b[d].width>=
|
||||
g&&f(c,b[d].name)}else{if("not-"===i){d=0;for(i=b.length;d<i;d++)-1===b[d].name.indexOf(g)&&f(c,b[d].name)}}else e[c].includeIn.push(d)};e.each(function(a,e){for(var d=a.className.split(" "),f=!1,j=0,l=d.length;j<l;j++){var k=c.trim(d[j]);if("all"===k){f=!0;a.includeIn=c.map(b,function(a){return a.name});return}if("none"===k||a.never){f=!0;return}if("control"===k){f=!0;a.control=!0;return}c.each(b,function(a,b){var d=b.name.split("-"),c=k.match(RegExp("(min\\-|max\\-|not\\-)?("+d[0]+")(\\-[_a-zA-Z0-9])?"));
|
||||
c&&(f=!0,c[2]===d[0]&&c[3]==="-"+d[1]?g(e,b.name,c[1],c[2]+c[3]):c[2]===d[0]&&!c[3]&&g(e,b.name,c[1],c[2]))})}f||(a.auto=!0)});this.s.columns=e},_detailsDisplay:function(a,b){var d=this,e=this.s.dt,f=this.c.details;if(f&&f.type){var g=f.display(a,b,function(){return f.renderer(e,a[0],d._detailsObj(a[0]))});(!0===g||!1===g)&&c(e.table().node()).triggerHandler("responsive-display.dt",[e,a,g,b])}},_detailsInit:function(){var a=this,b=this.s.dt,d=this.c.details;"inline"===d.type&&(d.target="td:first-child, th:first-child");
|
||||
b.on("draw.dtr",function(){a._tabIndexes()});a._tabIndexes();c(b.table().body()).on("keyup.dtr","td, th",function(a){a.keyCode===13&&c(this).data("dtr-keyboard")&&c(this).click()});var e=d.target;c(b.table().body()).on("click.dtr mousedown.dtr mouseup.dtr","string"===typeof e?e:"td, th",function(d){if(c(b.table().node()).hasClass("collapsed")&&b.row(c(this).closest("tr")).length){if(typeof e==="number"){var g=e<0?b.columns().eq(0).length+e:e;if(b.cell(this).index().column!==g)return}g=b.row(c(this).closest("tr"));
|
||||
d.type==="click"?a._detailsDisplay(g,false):d.type==="mousedown"?c(this).css("outline","none"):d.type==="mouseup"&&c(this).blur().css("outline","")}})},_detailsObj:function(a){var b=this,d=this.s.dt;return c.map(this.s.columns,function(e,c){if(!e.never)return{title:d.settings()[0].aoColumns[c].sTitle,data:d.cell(a,c).render(b.c.orthogonal),hidden:d.column(c).visible()&&!b.s.current[c],columnIndex:c,rowIndex:a}})},_find:function(a){for(var b=this.c.breakpoints,d=0,c=b.length;d<c;d++)if(b[d].name===
|
||||
a)return b[d]},_redrawChildren:function(){var a=this,b=this.s.dt;b.rows({page:"current"}).iterator("row",function(d,c){b.row(c);a._detailsDisplay(b.row(c),!0)})},_resize:function(){var a=this,b=this.s.dt,d=c(j).width(),e=this.c.breakpoints,f=e[0].name,g=this.s.columns,h,m=this.s.current.slice();for(h=e.length-1;0<=h;h--)if(d<=e[h].width){f=e[h].name;break}var i=this._columnsVisiblity(f);this.s.current=i;e=!1;h=0;for(d=g.length;h<d;h++)if(!1===i[h]&&!g[h].never&&!g[h].control){e=!0;break}c(b.table().node()).toggleClass("collapsed",
|
||||
e);var k=!1;b.columns().eq(0).each(function(b,c){i[c]!==m[c]&&(k=!0,a._setColumnVis(b,i[c]))});k&&(this._redrawChildren(),c(b.table().node()).trigger("responsive-resize.dt",[b,this.s.current]))},_resizeAuto:function(){var a=this.s.dt,b=this.s.columns;if(this.c.auto&&-1!==c.inArray(!0,c.map(b,function(a){return a.auto}))){a.table().node();var d=a.table().node().cloneNode(!1),e=c(a.table().header().cloneNode(!1)).appendTo(d),f=c(a.table().body()).clone(!1,!1).empty().appendTo(d),g=a.columns().header().filter(function(b){return a.column(b).visible()}).to$().clone(!1).css("display",
|
||||
"table-cell");c(f).append(c(a.rows({page:"current"}).nodes()).clone(!1)).find("th, td").css("display","");if(f=a.table().footer()){var f=c(f.cloneNode(!1)).appendTo(d),h=a.columns().header().filter(function(b){return a.column(b).visible()}).to$().clone(!1).css("display","table-cell");c("<tr/>").append(h).appendTo(f)}c("<tr/>").append(g).appendTo(e);"inline"===this.c.details.type&&c(d).addClass("dtr-inline collapsed");d=c("<div/>").css({width:1,height:1,overflow:"hidden"}).append(d);d.insertBefore(a.table().node());
|
||||
g.each(function(c){c=a.column.index("fromVisible",c);b[c].minWidth=this.offsetWidth||0});d.remove()}},_setColumnVis:function(a,b){var d=this.s.dt,e=b?"":"none";c(d.column(a).header()).css("display",e);c(d.column(a).footer()).css("display",e);d.column(a).nodes().to$().css("display",e)},_tabIndexes:function(){var a=this.s.dt,b=a.cells({page:"current"}).nodes().to$(),d=a.settings()[0],e=this.c.details.target;b.filter("[data-dtr-keyboard]").removeData("[data-dtr-keyboard]");c("number"===typeof e?":eq("+
|
||||
e+")":e,a.rows({page:"current"}).nodes()).attr("tabIndex",d.iTabIndex).data("dtr-keyboard",1)}});l.breakpoints=[{name:"desktop",width:Infinity},{name:"tablet-l",width:1024},{name:"tablet-p",width:768},{name:"mobile-l",width:480},{name:"mobile-p",width:320}];l.display={childRow:function(a,b,d){if(b){if(c(a.node()).hasClass("parent"))return a.child(d(),"child").show(),!0}else{if(a.child.isShown())return a.child(!1),c(a.node()).removeClass("parent"),!1;a.child(d(),"child").show();c(a.node()).addClass("parent");
|
||||
return!0}},childRowImmediate:function(a,b,d){if(!b&&a.child.isShown()||!a.responsive.hasHidden())return a.child(!1),c(a.node()).removeClass("parent"),!1;a.child(d(),"child").show();c(a.node()).addClass("parent");return!0},modal:function(a){return function(b,d,e){if(d)c("div.dtr-modal-content").empty().append(e());else{var f=function(){g.remove();c(k).off("keypress.dtr")},g=c('<div class="dtr-modal"/>').append(c('<div class="dtr-modal-display"/>').append(c('<div class="dtr-modal-content"/>').append(e())).append(c('<div class="dtr-modal-close">×</div>').click(function(){f()}))).append(c('<div class="dtr-modal-background"/>').click(function(){f()})).appendTo("body");
|
||||
c(k).on("keyup.dtr",function(a){27===a.keyCode&&(a.stopPropagation(),f())})}a&&a.header&&c("div.dtr-modal-content").prepend("<h2>"+a.header(b)+"</h2>")}}};l.defaults={breakpoints:l.breakpoints,auto:!0,details:{display:l.display.childRow,renderer:function(a,b,d){return(a=c.map(d,function(a){return a.hidden?'<li data-dtr-index="'+a.columnIndex+'" data-dt-row="'+a.rowIndex+'" data-dt-column="'+a.columnIndex+'"><span class="dtr-title">'+a.title+'</span> <span class="dtr-data">'+a.data+"</span></li>":
|
||||
""}).join(""))?c('<ul data-dtr-index="'+b+'"/>').append(a):!1},target:0,type:"inline"},orthogonal:"display"};var o=c.fn.dataTable.Api;o.register("responsive()",function(){return this});o.register("responsive.index()",function(a){a=c(a);return{column:a.data("dtr-index"),row:a.parent().data("dtr-index")}});o.register("responsive.rebuild()",function(){return this.iterator("table",function(a){a._responsive&&a._responsive._classLogic()})});o.register("responsive.recalc()",function(){return this.iterator("table",
|
||||
function(a){a._responsive&&(a._responsive._resizeAuto(),a._responsive._resize())})});o.register("responsive.hasHidden()",function(){var a=this.context[0];return a._responsive?-1!==c.inArray(!1,a._responsive.s.current):!1});l.version="2.0.2";c.fn.dataTable.Responsive=l;c.fn.DataTable.Responsive=l;c(k).on("preInit.dt.dtr",function(a,b){if("dt"===a.namespace&&(c(b.nTable).hasClass("responsive")||c(b.nTable).hasClass("dt-responsive")||b.oInit.responsive||n.defaults.responsive)){var d=b.oInit.responsive;
|
||||
!1!==d&&new l(b,c.isPlainObject(d)?d:{})}});return l});
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*! Scroller 1.2.2
|
||||
* ©2011-2014 SpryMedia Ltd - datatables.net/license
|
||||
/*! Scroller 1.4.1
|
||||
* ©2011-2016 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @summary Scroller
|
||||
* @description Virtual rendering for DataTables
|
||||
* @version 1.2.2
|
||||
* @version 1.4.1
|
||||
* @file dataTables.scroller.js
|
||||
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
||||
* @contact www.sprymedia.co.uk/contact
|
||||
* @copyright Copyright 2011-2014 SpryMedia Ltd.
|
||||
* @copyright Copyright 2011-2016 SpryMedia Ltd.
|
||||
*
|
||||
* This source file is free software, available under the following license:
|
||||
* MIT license - http://datatables.net/license/mit
|
||||
@@ -21,11 +21,35 @@
|
||||
* For details please refer to: http://www.datatables.net
|
||||
*/
|
||||
|
||||
(function(window, document, undefined){
|
||||
(function( factory ){
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
// AMD
|
||||
define( ['jquery', 'datatables.net'], function ( $ ) {
|
||||
return factory( $, window, document );
|
||||
} );
|
||||
}
|
||||
else if ( typeof exports === 'object' ) {
|
||||
// CommonJS
|
||||
module.exports = function (root, $) {
|
||||
if ( ! root ) {
|
||||
root = window;
|
||||
}
|
||||
|
||||
if ( ! $ || ! $.fn.dataTable ) {
|
||||
$ = require('datatables.net')(root, $).$;
|
||||
}
|
||||
|
||||
return factory( $, root, root.document );
|
||||
};
|
||||
}
|
||||
else {
|
||||
// Browser
|
||||
factory( jQuery, window, document );
|
||||
}
|
||||
}(function( $, window, document, undefined ) {
|
||||
'use strict';
|
||||
var DataTable = $.fn.dataTable;
|
||||
|
||||
var factory = function( $, DataTable ) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Scroller is a virtual rendering plug-in for DataTables which allows large
|
||||
@@ -48,7 +72,7 @@ var factory = function( $, DataTable ) {
|
||||
* Key features include:
|
||||
* <ul class="limit_length">
|
||||
* <li>Speed! The aim of Scroller for DataTables is to make rendering large data sets fast</li>
|
||||
* <li>Full compatibility with deferred rendering in DataTables 1.9 for maximum speed</li>
|
||||
* <li>Full compatibility with deferred rendering in DataTables for maximum speed</li>
|
||||
* <li>Display millions of rows</li>
|
||||
* <li>Integration with state saving in DataTables (scrolling position is saved)</li>
|
||||
* <li>Easy to use</li>
|
||||
@@ -57,34 +81,32 @@ var factory = function( $, DataTable ) {
|
||||
* @class
|
||||
* @constructor
|
||||
* @global
|
||||
* @param {object} oDT DataTables settings object
|
||||
* @param {object} [oOpts={}] Configuration object for FixedColumns. Options
|
||||
* @param {object} dt DataTables settings object or API instance
|
||||
* @param {object} [opts={}] Configuration object for FixedColumns. Options
|
||||
* are defined by {@link Scroller.defaults}
|
||||
*
|
||||
* @requires jQuery 1.7+
|
||||
* @requires DataTables 1.9.0+
|
||||
* @requires DataTables 1.10.0+
|
||||
*
|
||||
* @example
|
||||
* $(document).ready(function() {
|
||||
* $('#example').dataTable( {
|
||||
* "sScrollY": "200px",
|
||||
* "sAjaxSource": "media/dataset/large.txt",
|
||||
* "sDom": "frtiS",
|
||||
* "bDeferRender": true
|
||||
* $('#example').DataTable( {
|
||||
* "scrollY": "200px",
|
||||
* "ajax": "media/dataset/large.txt",
|
||||
* "dom": "frtiS",
|
||||
* "deferRender": true
|
||||
* } );
|
||||
* } );
|
||||
*/
|
||||
var Scroller = function ( oDTSettings, oOpts ) {
|
||||
var Scroller = function ( dt, opts ) {
|
||||
/* Sanity check - you just know it will happen */
|
||||
if ( ! this instanceof Scroller )
|
||||
{
|
||||
if ( ! (this instanceof Scroller) ) {
|
||||
alert( "Scroller warning: Scroller must be initialised with the 'new' keyword." );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( typeof oOpts == 'undefined' )
|
||||
{
|
||||
oOpts = {};
|
||||
if ( opts === undefined ) {
|
||||
opts = {};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +121,7 @@ var Scroller = function ( oDTSettings, oOpts ) {
|
||||
* @type object
|
||||
* @default Passed in as first parameter to constructor
|
||||
*/
|
||||
"dt": oDTSettings,
|
||||
"dt": $.fn.dataTable.Api( dt ).settings()[0],
|
||||
|
||||
/**
|
||||
* Pixel location of the top of the drawn table in the viewport
|
||||
@@ -193,7 +215,7 @@ var Scroller = function ( oDTSettings, oOpts ) {
|
||||
|
||||
// @todo The defaults should extend a `c` property and the internal settings
|
||||
// only held in the `s` property. At the moment they are mixed
|
||||
this.s = $.extend( this.s, Scroller.oDefaults, oOpts );
|
||||
this.s = $.extend( this.s, Scroller.oDefaults, opts );
|
||||
|
||||
// Workaround for row height being read from height object (see above comment)
|
||||
this.s.heights.row = this.s.rowHeight;
|
||||
@@ -211,7 +233,12 @@ var Scroller = function ( oDTSettings, oOpts ) {
|
||||
"loader": null
|
||||
};
|
||||
|
||||
/* Attach the instance to the DataTables instance so it can be accessed */
|
||||
// Attach the instance to the DataTables instance so it can be accessed in
|
||||
// future. Don't initialise Scroller twice on the same table
|
||||
if ( this.s.dt.oScroller ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.s.dt.oScroller = this;
|
||||
|
||||
/* Let's do it */
|
||||
@@ -220,7 +247,7 @@ var Scroller = function ( oDTSettings, oOpts ) {
|
||||
|
||||
|
||||
|
||||
Scroller.prototype = /** @lends Scroller.prototype */{
|
||||
$.extend( Scroller.prototype, {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
@@ -404,17 +431,43 @@ Scroller.prototype = /** @lends Scroller.prototype */{
|
||||
|
||||
var heights = this.s.heights;
|
||||
|
||||
heights.viewport = $(this.dom.scroller).height();
|
||||
this.s.viewportRows = parseInt( heights.viewport / heights.row, 10 )+1;
|
||||
this.s.dt._iDisplayLength = this.s.viewportRows * this.s.displayBuffer;
|
||||
if ( heights.row ) {
|
||||
heights.viewport = $(this.dom.scroller).height();
|
||||
this.s.viewportRows = parseInt( heights.viewport / heights.row, 10 )+1;
|
||||
this.s.dt._iDisplayLength = this.s.viewportRows * this.s.displayBuffer;
|
||||
}
|
||||
|
||||
if ( bRedraw === undefined || bRedraw )
|
||||
{
|
||||
this.s.dt.oInstance.fnDraw();
|
||||
this.s.dt.oInstance.fnDraw( false );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Get information about current displayed record range. This corresponds to
|
||||
* the information usually displayed in the "Info" block of the table.
|
||||
*
|
||||
* @returns {object} info as an object:
|
||||
* {
|
||||
* start: {int}, // the 0-indexed record at the top of the viewport
|
||||
* end: {int}, // the 0-indexed record at the bottom of the viewport
|
||||
* }
|
||||
*/
|
||||
"fnPageInfo": function()
|
||||
{
|
||||
var
|
||||
dt = this.s.dt,
|
||||
iScrollTop = this.dom.scroller.scrollTop,
|
||||
iTotal = dt.fnRecordsDisplay(),
|
||||
iPossibleEnd = Math.ceil(this.fnPixelsToRow(iScrollTop + this.s.heights.viewport, false, this.s.ani));
|
||||
|
||||
return {
|
||||
start: Math.floor(this.fnPixelsToRow(iScrollTop, false, this.s.ani)),
|
||||
end: iTotal < iPossibleEnd ? iTotal-1 : iPossibleEnd-1
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private methods (they are of course public in JS, but recommended as private)
|
||||
@@ -438,7 +491,7 @@ Scroller.prototype = /** @lends Scroller.prototype */{
|
||||
/* Insert a div element that we can use to force the DT scrolling container to
|
||||
* the height that would be required if the whole table was being displayed
|
||||
*/
|
||||
this.dom.force.style.position = "absolute";
|
||||
this.dom.force.style.position = "relative";
|
||||
this.dom.force.style.top = "0px";
|
||||
this.dom.force.style.left = "0px";
|
||||
this.dom.force.style.width = "1px";
|
||||
@@ -458,7 +511,7 @@ Scroller.prototype = /** @lends Scroller.prototype */{
|
||||
// Add a 'loading' indicator
|
||||
if ( this.s.loadingIndicator )
|
||||
{
|
||||
this.dom.loader = $('<div class="DTS_Loading">'+this.s.dt.oLanguage.sLoadingRecords+'</div>')
|
||||
this.dom.loader = $('<div class="dataTables_processing DTS_Loading">'+this.s.dt.oLanguage.sLoadingRecords+'</div>')
|
||||
.css('display', 'none');
|
||||
|
||||
$(this.dom.scroller.parentNode)
|
||||
@@ -529,6 +582,14 @@ Scroller.prototype = /** @lends Scroller.prototype */{
|
||||
this.s.topRowFloat = this.s.dt.oLoadedState.iScrollerTopRow || 0;
|
||||
}
|
||||
|
||||
// Measure immediately. Scroller will have been added using preInit, so
|
||||
// we can reliably do this here. We could potentially also measure on
|
||||
// init complete, which would be useful for cases where the data is Ajax
|
||||
// loaded and longer than a single line.
|
||||
$(this.s.dt.nTable).one( 'init.dt', function () {
|
||||
that.fnMeasure();
|
||||
} );
|
||||
|
||||
/* Destructor */
|
||||
this.s.dt.aoDestroyCallback.push( {
|
||||
"sName": "Scroller",
|
||||
@@ -537,6 +598,7 @@ Scroller.prototype = /** @lends Scroller.prototype */{
|
||||
$(that.dom.scroller).off('touchstart.DTS scroll.DTS');
|
||||
$(that.s.dt.nTableWrapper).removeClass('DTS');
|
||||
$('div.DTS_Loading', that.dom.scroller.parentNode).remove();
|
||||
$(that.s.dt.nTable).off( 'init.dt' );
|
||||
|
||||
that.dom.table.style.position = "";
|
||||
that.dom.table.style.top = "";
|
||||
@@ -635,9 +697,6 @@ Scroller.prototype = /** @lends Scroller.prototype */{
|
||||
}
|
||||
|
||||
that.s.dt._iDisplayStart = iTopRow;
|
||||
if ( that.s.dt.oApi._fnCalculateEnd ) { // Removed in 1.10
|
||||
that.s.dt.oApi._fnCalculateEnd( that.s.dt );
|
||||
}
|
||||
that.s.dt.oApi._fnDraw( that.s.dt );
|
||||
};
|
||||
|
||||
@@ -682,14 +741,7 @@ Scroller.prototype = /** @lends Scroller.prototype */{
|
||||
// If the virtual and physical height match, then we use a linear
|
||||
// transform between the two, allowing the scrollbar to be linear
|
||||
if ( heights.virtual === heights.scroll ) {
|
||||
coeff = (heights.virtual-heights.viewport) / (heights.scroll-heights.viewport);
|
||||
|
||||
if ( dir === 'virtualToPhysical' ) {
|
||||
return val / coeff;
|
||||
}
|
||||
else if ( dir === 'physicalToVirtual' ) {
|
||||
return val * coeff;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
// Otherwise, we want a non-linear scrollbar to take account of the
|
||||
@@ -832,10 +884,12 @@ Scroller.prototype = /** @lends Scroller.prototype */{
|
||||
|
||||
// Because of the order of the DT callbacks, the info update will
|
||||
// take precedence over the one we want here. So a 'thread' break is
|
||||
// needed
|
||||
setTimeout( function () {
|
||||
that._fnInfo.call( that );
|
||||
}, 0 );
|
||||
// needed. Only add the thread break if bInfo is set
|
||||
if ( this.s.dt.oFeatures.bInfo ) {
|
||||
setTimeout( function () {
|
||||
that._fnInfo.call( that );
|
||||
}, 0 );
|
||||
}
|
||||
|
||||
// Hide the loading indicator
|
||||
if ( this.dom.loader && this.s.loaderVisible ) {
|
||||
@@ -868,7 +922,11 @@ Scroller.prototype = /** @lends Scroller.prototype */{
|
||||
heights.scroll = max;
|
||||
}
|
||||
|
||||
this.dom.force.style.height = heights.scroll+"px";
|
||||
// Minimum height so there is always a row visible (the 'no rows found'
|
||||
// if reduced to zero filtering)
|
||||
this.dom.force.style.height = heights.scroll > this.s.heights.row ?
|
||||
heights.scroll+'px' :
|
||||
this.s.heights.row+'px';
|
||||
},
|
||||
|
||||
|
||||
@@ -903,18 +961,16 @@ Scroller.prototype = /** @lends Scroller.prototype */{
|
||||
|
||||
$('div.'+dt.oClasses.sScrollBody, container).append( nTable );
|
||||
|
||||
var appendTo;
|
||||
if (dt._bInitComplete) {
|
||||
appendTo = origTable.parentNode;
|
||||
} else {
|
||||
if (!this.s.dt.nHolding) {
|
||||
this.s.dt.nHolding = $( '<div></div>' ).insertBefore( this.s.dt.nTable );
|
||||
}
|
||||
appendTo = this.s.dt.nHolding;
|
||||
// If initialised using `dom`, use the holding element as the insert point
|
||||
var insertEl = this.s.dt.nHolding || origTable.parentNode;
|
||||
|
||||
if ( ! $(insertEl).is(':visible') ) {
|
||||
insertEl = 'body';
|
||||
}
|
||||
|
||||
container.appendTo( appendTo );
|
||||
container.appendTo( insertEl );
|
||||
this.s.heights.row = $('tr', tbody).eq(1).outerHeight();
|
||||
|
||||
container.remove();
|
||||
},
|
||||
|
||||
@@ -1002,7 +1058,7 @@ Scroller.prototype = /** @lends Scroller.prototype */{
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} );
|
||||
|
||||
|
||||
|
||||
@@ -1155,7 +1211,7 @@ Scroller.oDefaults = Scroller.defaults;
|
||||
* @name Scroller.version
|
||||
* @static
|
||||
*/
|
||||
Scroller.version = "1.2.2";
|
||||
Scroller.version = "1.4.1";
|
||||
|
||||
|
||||
|
||||
@@ -1163,19 +1219,17 @@ Scroller.version = "1.2.2";
|
||||
* Initialisation
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*
|
||||
* Register a new feature with DataTables
|
||||
*/
|
||||
// Legacy `dom` parameter initialisation support
|
||||
if ( typeof $.fn.dataTable == "function" &&
|
||||
typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
|
||||
$.fn.dataTableExt.fnVersionCheck('1.9.0') )
|
||||
$.fn.dataTableExt.fnVersionCheck('1.10.0') )
|
||||
{
|
||||
$.fn.dataTableExt.aoFeatures.push( {
|
||||
"fnInit": function( oDTSettings ) {
|
||||
var init = oDTSettings.oInit;
|
||||
var opts = init.scroller || init.oScroller || {};
|
||||
var oScroller = new Scroller( oDTSettings, opts );
|
||||
return oScroller.dom.wrapper;
|
||||
|
||||
new Scroller( oDTSettings, opts );
|
||||
},
|
||||
"cFeature": "S",
|
||||
"sFeature": "Scroller"
|
||||
@@ -1183,9 +1237,28 @@ if ( typeof $.fn.dataTable == "function" &&
|
||||
}
|
||||
else
|
||||
{
|
||||
alert( "Warning: Scroller requires DataTables 1.9.0 or greater - www.datatables.net/download");
|
||||
alert( "Warning: Scroller requires DataTables 1.10.0 or greater - www.datatables.net/download");
|
||||
}
|
||||
|
||||
// Attach a listener to the document which listens for DataTables initialisation
|
||||
// events so we can automatically initialise
|
||||
$(document).on( 'preInit.dt.dtscroller', function (e, settings) {
|
||||
if ( e.namespace !== 'dt' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var init = settings.oInit.scroller;
|
||||
var defaults = DataTable.defaults.scroller;
|
||||
|
||||
if ( init || defaults ) {
|
||||
var opts = $.extend( {}, init, defaults );
|
||||
|
||||
if ( init !== false ) {
|
||||
new Scroller( settings, opts );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
// Attach Scroller to DataTables so it can be accessed as an 'extra'
|
||||
$.fn.dataTable.Scroller = Scroller;
|
||||
@@ -1193,70 +1266,78 @@ $.fn.DataTable.Scroller = Scroller;
|
||||
|
||||
|
||||
// DataTables 1.10 API method aliases
|
||||
if ( $.fn.dataTable.Api ) {
|
||||
var Api = $.fn.dataTable.Api;
|
||||
var Api = $.fn.dataTable.Api;
|
||||
|
||||
Api.register( 'scroller()', function () {
|
||||
return this;
|
||||
} );
|
||||
Api.register( 'scroller()', function () {
|
||||
return this;
|
||||
} );
|
||||
|
||||
Api.register( 'scroller().rowToPixels()', function ( rowIdx, intParse, virtual ) {
|
||||
var ctx = this.context;
|
||||
// Undocumented and deprecated - is it actually useful at all?
|
||||
Api.register( 'scroller().rowToPixels()', function ( rowIdx, intParse, virtual ) {
|
||||
var ctx = this.context;
|
||||
|
||||
if ( ctx.length && ctx[0].oScroller ) {
|
||||
return ctx[0].oScroller.fnRowToPixels( rowIdx, intParse, virtual );
|
||||
if ( ctx.length && ctx[0].oScroller ) {
|
||||
return ctx[0].oScroller.fnRowToPixels( rowIdx, intParse, virtual );
|
||||
}
|
||||
// undefined
|
||||
} );
|
||||
|
||||
// Undocumented and deprecated - is it actually useful at all?
|
||||
Api.register( 'scroller().pixelsToRow()', function ( pixels, intParse, virtual ) {
|
||||
var ctx = this.context;
|
||||
|
||||
if ( ctx.length && ctx[0].oScroller ) {
|
||||
return ctx[0].oScroller.fnPixelsToRow( pixels, intParse, virtual );
|
||||
}
|
||||
// undefined
|
||||
} );
|
||||
|
||||
// Undocumented and deprecated - use `row().scrollTo()` instead
|
||||
Api.register( 'scroller().scrollToRow()', function ( row, ani ) {
|
||||
this.iterator( 'table', function ( ctx ) {
|
||||
if ( ctx.oScroller ) {
|
||||
ctx.oScroller.fnScrollToRow( row, ani );
|
||||
}
|
||||
// undefined
|
||||
} );
|
||||
|
||||
Api.register( 'scroller().pixelsToRow()', function ( pixels, intParse, virtual ) {
|
||||
var ctx = this.context;
|
||||
return this;
|
||||
} );
|
||||
|
||||
if ( ctx.length && ctx[0].oScroller ) {
|
||||
return ctx[0].oScroller.fnPixelsToRow( pixels, intParse, virtual );
|
||||
Api.register( 'row().scrollTo()', function ( ani ) {
|
||||
var that = this;
|
||||
|
||||
this.iterator( 'row', function ( ctx, rowIdx ) {
|
||||
if ( ctx.oScroller ) {
|
||||
var displayIdx = that
|
||||
.rows( { order: 'applied', search: 'applied' } )
|
||||
.indexes()
|
||||
.indexOf( rowIdx );
|
||||
|
||||
ctx.oScroller.fnScrollToRow( displayIdx, ani );
|
||||
}
|
||||
// undefined
|
||||
} );
|
||||
|
||||
Api.register( 'scroller().scrollToRow()', function ( row, ani ) {
|
||||
this.iterator( 'table', function ( ctx ) {
|
||||
if ( ctx.oScroller ) {
|
||||
ctx.oScroller.fnScrollToRow( row, ani );
|
||||
}
|
||||
} );
|
||||
return this;
|
||||
} );
|
||||
|
||||
return this;
|
||||
Api.register( 'scroller.measure()', function ( redraw ) {
|
||||
this.iterator( 'table', function ( ctx ) {
|
||||
if ( ctx.oScroller ) {
|
||||
ctx.oScroller.fnMeasure( redraw );
|
||||
}
|
||||
} );
|
||||
|
||||
Api.register( 'scroller().measure()', function ( redraw ) {
|
||||
this.iterator( 'table', function ( ctx ) {
|
||||
if ( ctx.oScroller ) {
|
||||
ctx.oScroller.fnMeasure( redraw );
|
||||
}
|
||||
} );
|
||||
return this;
|
||||
} );
|
||||
|
||||
return this;
|
||||
} );
|
||||
}
|
||||
Api.register( 'scroller.page()', function() {
|
||||
var ctx = this.context;
|
||||
|
||||
if ( ctx.length && ctx[0].oScroller ) {
|
||||
return ctx[0].oScroller.fnPageInfo();
|
||||
}
|
||||
// undefined
|
||||
} );
|
||||
|
||||
return Scroller;
|
||||
}; // /factory
|
||||
|
||||
|
||||
// Define as an AMD module if possible
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
define( ['jquery', 'datatables'], factory );
|
||||
}
|
||||
else if ( typeof exports === 'object' ) {
|
||||
// Node/CommonJS
|
||||
factory( require('jquery'), require('datatables') );
|
||||
}
|
||||
else if ( jQuery && !jQuery.fn.dataTable.Scroller ) {
|
||||
// Otherwise simply initialise as normal, stopping multiple evaluation
|
||||
factory( jQuery, jQuery.fn.dataTable );
|
||||
}
|
||||
|
||||
|
||||
})(window, document);
|
||||
|
||||
}));
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
/*!
|
||||
Scroller 1.2.2
|
||||
©2011-2014 SpryMedia Ltd - datatables.net/license
|
||||
Scroller 1.4.1
|
||||
©2011-2016 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
(function(m,n,k){var l=function(e){var g=function(a,b){!this instanceof g?alert("Scroller warning: Scroller must be initialised with the 'new' keyword."):("undefined"==typeof b&&(b={}),this.s={dt:a,tableTop:0,tableBottom:0,redrawTop:0,redrawBottom:0,autoHeight:!0,viewportRows:0,stateTO:null,drawTO:null,heights:{jump:null,page:null,virtual:null,scroll:null,row:null,viewport:null},topRowFloat:0,scrollDrawDiff:null,loaderVisible:!1},this.s=e.extend(this.s,g.oDefaults,b),this.s.heights.row=this.s.rowHeight,
|
||||
this.dom={force:n.createElement("div"),scroller:null,table:null,loader:null},this.s.dt.oScroller=this,this._fnConstruct())};g.prototype={fnRowToPixels:function(a,b,c){a=c?this._domain("virtualToPhysical",a*this.s.heights.row):this.s.baseScrollTop+(a-this.s.baseRowTop)*this.s.heights.row;return b||b===k?parseInt(a,10):a},fnPixelsToRow:function(a,b,c){var d=a-this.s.baseScrollTop,a=c?this._domain("physicalToVirtual",a)/this.s.heights.row:d/this.s.heights.row+this.s.baseRowTop;return b||b===k?parseInt(a,
|
||||
10):a},fnScrollToRow:function(a,b){var c=this,d=!1,f=this.fnRowToPixels(a),h=a-(this.s.displayBuffer-1)/2*this.s.viewportRows;0>h&&(h=0);if((f>this.s.redrawBottom||f<this.s.redrawTop)&&this.s.dt._iDisplayStart!==h)d=!0,f=this.fnRowToPixels(a,!1,!0);"undefined"==typeof b||b?(this.s.ani=d,e(this.dom.scroller).animate({scrollTop:f},function(){setTimeout(function(){c.s.ani=!1},25)})):e(this.dom.scroller).scrollTop(f)},fnMeasure:function(a){this.s.autoHeight&&this._fnCalcRowHeight();var b=this.s.heights;
|
||||
b.viewport=e(this.dom.scroller).height();this.s.viewportRows=parseInt(b.viewport/b.row,10)+1;this.s.dt._iDisplayLength=this.s.viewportRows*this.s.displayBuffer;(a===k||a)&&this.s.dt.oInstance.fnDraw()},_fnConstruct:function(){var a=this;if(this.s.dt.oFeatures.bPaginate){this.dom.force.style.position="absolute";this.dom.force.style.top="0px";this.dom.force.style.left="0px";this.dom.force.style.width="1px";this.dom.scroller=e("div."+this.s.dt.oClasses.sScrollBody,this.s.dt.nTableWrapper)[0];this.dom.scroller.appendChild(this.dom.force);
|
||||
this.dom.scroller.style.position="relative";this.dom.table=e(">table",this.dom.scroller)[0];this.dom.table.style.position="absolute";this.dom.table.style.top="0px";this.dom.table.style.left="0px";e(this.s.dt.nTableWrapper).addClass("DTS");this.s.loadingIndicator&&(this.dom.loader=e('<div class="DTS_Loading">'+this.s.dt.oLanguage.sLoadingRecords+"</div>").css("display","none"),e(this.dom.scroller.parentNode).css("position","relative").append(this.dom.loader));this.s.heights.row&&"auto"!=this.s.heights.row&&
|
||||
(this.s.autoHeight=!1);this.fnMeasure(!1);this.s.ingnoreScroll=!0;this.s.stateSaveThrottle=this.s.dt.oApi._fnThrottle(function(){a.s.dt.oApi._fnSaveState(a.s.dt)},500);e(this.dom.scroller).on("scroll.DTS",function(){a._fnScroll.call(a)});e(this.dom.scroller).on("touchstart.DTS",function(){a._fnScroll.call(a)});this.s.dt.aoDrawCallback.push({fn:function(){a.s.dt.bInitialised&&a._fnDrawCallback.call(a)},sName:"Scroller"});e(m).on("resize.DTS",function(){a.fnMeasure(false);a._fnInfo()});var b=!0;this.s.dt.oApi._fnCallbackReg(this.s.dt,
|
||||
"aoStateSaveParams",function(c,d){if(b&&a.s.dt.oLoadedState){d.iScroller=a.s.dt.oLoadedState.iScroller;d.iScrollerTopRow=a.s.dt.oLoadedState.iScrollerTopRow;b=false}else{d.iScroller=a.dom.scroller.scrollTop;d.iScrollerTopRow=a.s.topRowFloat}},"Scroller_State");this.s.dt.oLoadedState&&(this.s.topRowFloat=this.s.dt.oLoadedState.iScrollerTopRow||0);this.s.dt.aoDestroyCallback.push({sName:"Scroller",fn:function(){e(m).off("resize.DTS");e(a.dom.scroller).off("touchstart.DTS scroll.DTS");e(a.s.dt.nTableWrapper).removeClass("DTS");
|
||||
e("div.DTS_Loading",a.dom.scroller.parentNode).remove();a.dom.table.style.position="";a.dom.table.style.top="";a.dom.table.style.left=""}})}else this.s.dt.oApi._fnLog(this.s.dt,0,"Pagination must be enabled for Scroller")},_fnScroll:function(){var a=this,b=this.s.heights,c=this.dom.scroller.scrollTop,d;if(!this.s.skip&&!this.s.ingnoreScroll)if(this.s.dt.bFiltered||this.s.dt.bSorted)this.s.lastScrollTop=0;else{this._fnInfo();clearTimeout(this.s.stateTO);this.s.stateTO=setTimeout(function(){a.s.dt.oApi._fnSaveState(a.s.dt)},
|
||||
250);if(c<this.s.redrawTop||c>this.s.redrawBottom){var f=Math.ceil((this.s.displayBuffer-1)/2*this.s.viewportRows);Math.abs(c-this.s.lastScrollTop)>b.viewport||this.s.ani?(d=parseInt(this._domain("physicalToVirtual",c)/b.row,10)-f,this.s.topRowFloat=this._domain("physicalToVirtual",c)/b.row):(d=this.fnPixelsToRow(c)-f,this.s.topRowFloat=this.fnPixelsToRow(c,!1));0>=d?d=0:d+this.s.dt._iDisplayLength>this.s.dt.fnRecordsDisplay()?(d=this.s.dt.fnRecordsDisplay()-this.s.dt._iDisplayLength,0>d&&(d=0)):
|
||||
0!==d%2&&d++;if(d!=this.s.dt._iDisplayStart&&(this.s.tableTop=e(this.s.dt.nTable).offset().top,this.s.tableBottom=e(this.s.dt.nTable).height()+this.s.tableTop,b=function(){if(a.s.scrollDrawReq===null)a.s.scrollDrawReq=c;a.s.dt._iDisplayStart=d;a.s.dt.oApi._fnCalculateEnd&&a.s.dt.oApi._fnCalculateEnd(a.s.dt);a.s.dt.oApi._fnDraw(a.s.dt)},this.s.dt.oFeatures.bServerSide?(clearTimeout(this.s.drawTO),this.s.drawTO=setTimeout(b,this.s.serverWait)):b(),this.dom.loader&&!this.s.loaderVisible))this.dom.loader.css("display",
|
||||
"block"),this.s.loaderVisible=!0}this.s.lastScrollTop=c;this.s.stateSaveThrottle()}},_domain:function(a,b){var c=this.s.heights,d;if(c.virtual===c.scroll){d=(c.virtual-c.viewport)/(c.scroll-c.viewport);if("virtualToPhysical"===a)return b/d;if("physicalToVirtual"===a)return b*d}var e=(c.scroll-c.viewport)/2,h=(c.virtual-c.viewport)/2;d=h/(e*e);if("virtualToPhysical"===a){if(b<h)return Math.pow(b/d,0.5);b=2*h-b;return 0>b?c.scroll:2*e-Math.pow(b/d,0.5)}if("physicalToVirtual"===a){if(b<e)return b*b*
|
||||
d;b=2*e-b;return 0>b?c.virtual:2*h-b*b*d}},_fnDrawCallback:function(){var a=this,b=this.s.heights,c=this.dom.scroller.scrollTop,d=e(this.s.dt.nTable).height(),f=this.s.dt._iDisplayStart,h=this.s.dt._iDisplayLength,g=this.s.dt.fnRecordsDisplay();this.s.skip=!0;this._fnScrollForce();c=0===f?this.s.topRowFloat*b.row:f+h>=g?b.scroll-(g-this.s.topRowFloat)*b.row:this._domain("virtualToPhysical",this.s.topRowFloat*b.row);this.dom.scroller.scrollTop=c;this.s.baseScrollTop=c;this.s.baseRowTop=this.s.topRowFloat;
|
||||
var j=c-(this.s.topRowFloat-f)*b.row;0===f?j=0:f+h>=g&&(j=b.scroll-d);this.dom.table.style.top=j+"px";this.s.tableTop=j;this.s.tableBottom=d+this.s.tableTop;d=(c-this.s.tableTop)*this.s.boundaryScale;this.s.redrawTop=c-d;this.s.redrawBottom=c+d;this.s.skip=!1;this.s.dt.oFeatures.bStateSave&&null!==this.s.dt.oLoadedState&&"undefined"!=typeof this.s.dt.oLoadedState.iScroller?((c=(this.s.dt.sAjaxSource||a.s.dt.ajax)&&!this.s.dt.oFeatures.bServerSide?!0:!1)&&2==this.s.dt.iDraw||!c&&1==this.s.dt.iDraw)&&
|
||||
setTimeout(function(){e(a.dom.scroller).scrollTop(a.s.dt.oLoadedState.iScroller);a.s.redrawTop=a.s.dt.oLoadedState.iScroller-b.viewport/2;setTimeout(function(){a.s.ingnoreScroll=!1},0)},0):a.s.ingnoreScroll=!1;setTimeout(function(){a._fnInfo.call(a)},0);this.dom.loader&&this.s.loaderVisible&&(this.dom.loader.css("display","none"),this.s.loaderVisible=!1)},_fnScrollForce:function(){var a=this.s.heights;a.virtual=a.row*this.s.dt.fnRecordsDisplay();a.scroll=a.virtual;1E6<a.scroll&&(a.scroll=1E6);this.dom.force.style.height=
|
||||
a.scroll+"px"},_fnCalcRowHeight:function(){var a=this.s.dt,b=a.nTable,c=b.cloneNode(!1),d=e("<tbody/>").appendTo(c),f=e('<div class="'+a.oClasses.sWrapper+' DTS"><div class="'+a.oClasses.sScrollWrapper+'"><div class="'+a.oClasses.sScrollBody+'"></div></div></div>');for(e("tbody tr:lt(4)",b).clone().appendTo(d);3>e("tr",d).length;)d.append("<tr><td> </td></tr>");e("div."+a.oClasses.sScrollBody,f).append(c);a._bInitComplete?a=b.parentNode:(this.s.dt.nHolding||(this.s.dt.nHolding=e("<div></div>").insertBefore(this.s.dt.nTable)),
|
||||
a=this.s.dt.nHolding);f.appendTo(a);this.s.heights.row=e("tr",d).eq(1).outerHeight();f.remove()},_fnInfo:function(){if(this.s.dt.oFeatures.bInfo){var a=this.s.dt,b=a.oLanguage,c=this.dom.scroller.scrollTop,d=Math.floor(this.fnPixelsToRow(c,!1,this.s.ani)+1),f=a.fnRecordsTotal(),h=a.fnRecordsDisplay(),c=Math.ceil(this.fnPixelsToRow(c+this.s.heights.viewport,!1,this.s.ani)),c=h<c?h:c,g=a.fnFormatNumber(d),j=a.fnFormatNumber(c),i=a.fnFormatNumber(f),k=a.fnFormatNumber(h),g=0===a.fnRecordsDisplay()&&
|
||||
a.fnRecordsDisplay()==a.fnRecordsTotal()?b.sInfoEmpty+b.sInfoPostFix:0===a.fnRecordsDisplay()?b.sInfoEmpty+" "+b.sInfoFiltered.replace("_MAX_",i)+b.sInfoPostFix:a.fnRecordsDisplay()==a.fnRecordsTotal()?b.sInfo.replace("_START_",g).replace("_END_",j).replace("_MAX_",i).replace("_TOTAL_",k)+b.sInfoPostFix:b.sInfo.replace("_START_",g).replace("_END_",j).replace("_MAX_",i).replace("_TOTAL_",k)+" "+b.sInfoFiltered.replace("_MAX_",a.fnFormatNumber(a.fnRecordsTotal()))+b.sInfoPostFix;(b=b.fnInfoCallback)&&
|
||||
(g=b.call(a.oInstance,a,d,c,f,h,g));a=a.aanFeatures.i;if("undefined"!=typeof a){d=0;for(f=a.length;d<f;d++)e(a[d]).html(g)}}}};g.defaults={trace:!1,rowHeight:"auto",serverWait:200,displayBuffer:9,boundaryScale:0.5,loadingIndicator:!1};g.oDefaults=g.defaults;g.version="1.2.2";"function"==typeof e.fn.dataTable&&"function"==typeof e.fn.dataTableExt.fnVersionCheck&&e.fn.dataTableExt.fnVersionCheck("1.9.0")?e.fn.dataTableExt.aoFeatures.push({fnInit:function(a){var b=a.oInit;return(new g(a,b.scroller||
|
||||
b.oScroller||{})).dom.wrapper},cFeature:"S",sFeature:"Scroller"}):alert("Warning: Scroller requires DataTables 1.9.0 or greater - www.datatables.net/download");e.fn.dataTable.Scroller=g;e.fn.DataTable.Scroller=g;if(e.fn.dataTable.Api){var i=e.fn.dataTable.Api;i.register("scroller()",function(){return this});i.register("scroller().rowToPixels()",function(a,b,c){var d=this.context;if(d.length&&d[0].oScroller)return d[0].oScroller.fnRowToPixels(a,b,c)});i.register("scroller().pixelsToRow()",function(a,
|
||||
b,c){var d=this.context;if(d.length&&d[0].oScroller)return d[0].oScroller.fnPixelsToRow(a,b,c)});i.register("scroller().scrollToRow()",function(a,b){this.iterator("table",function(c){c.oScroller&&c.oScroller.fnScrollToRow(a,b)});return this});i.register("scroller().measure()",function(a){this.iterator("table",function(b){b.oScroller&&b.oScroller.fnMeasure(a)});return this})}return g};"function"===typeof define&&define.amd?define(["jquery","datatables"],l):"object"===typeof exports?l(require("jquery"),
|
||||
require("datatables")):jQuery&&!jQuery.fn.dataTable.Scroller&&l(jQuery,jQuery.fn.dataTable)})(window,document);
|
||||
(function(e){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(g){return e(g,window,document)}):"object"===typeof exports?module.exports=function(g,i){g||(g=window);if(!i||!i.fn.dataTable)i=require("datatables.net")(g,i).$;return e(i,g,g.document)}:e(jQuery,window,document)})(function(e,g,i,l){var m=e.fn.dataTable,h=function(a,b){this instanceof h?(b===l&&(b={}),this.s={dt:e.fn.dataTable.Api(a).settings()[0],tableTop:0,tableBottom:0,redrawTop:0,redrawBottom:0,autoHeight:!0,
|
||||
viewportRows:0,stateTO:null,drawTO:null,heights:{jump:null,page:null,virtual:null,scroll:null,row:null,viewport:null},topRowFloat:0,scrollDrawDiff:null,loaderVisible:!1},this.s=e.extend(this.s,h.oDefaults,b),this.s.heights.row=this.s.rowHeight,this.dom={force:i.createElement("div"),scroller:null,table:null,loader:null},this.s.dt.oScroller||(this.s.dt.oScroller=this,this._fnConstruct())):alert("Scroller warning: Scroller must be initialised with the 'new' keyword.")};e.extend(h.prototype,{fnRowToPixels:function(a,
|
||||
b,c){a=c?this._domain("virtualToPhysical",a*this.s.heights.row):this.s.baseScrollTop+(a-this.s.baseRowTop)*this.s.heights.row;return b||b===l?parseInt(a,10):a},fnPixelsToRow:function(a,b,c){var d=a-this.s.baseScrollTop,a=c?this._domain("physicalToVirtual",a)/this.s.heights.row:d/this.s.heights.row+this.s.baseRowTop;return b||b===l?parseInt(a,10):a},fnScrollToRow:function(a,b){var c=this,d=!1,f=this.fnRowToPixels(a),j=a-(this.s.displayBuffer-1)/2*this.s.viewportRows;0>j&&(j=0);if((f>this.s.redrawBottom||
|
||||
f<this.s.redrawTop)&&this.s.dt._iDisplayStart!==j)d=!0,f=this.fnRowToPixels(a,!1,!0);"undefined"==typeof b||b?(this.s.ani=d,e(this.dom.scroller).animate({scrollTop:f},function(){setTimeout(function(){c.s.ani=!1},25)})):e(this.dom.scroller).scrollTop(f)},fnMeasure:function(a){this.s.autoHeight&&this._fnCalcRowHeight();var b=this.s.heights;b.row&&(b.viewport=e(this.dom.scroller).height(),this.s.viewportRows=parseInt(b.viewport/b.row,10)+1,this.s.dt._iDisplayLength=this.s.viewportRows*this.s.displayBuffer);
|
||||
(a===l||a)&&this.s.dt.oInstance.fnDraw(!1)},fnPageInfo:function(){var a=this.dom.scroller.scrollTop,b=this.s.dt.fnRecordsDisplay(),c=Math.ceil(this.fnPixelsToRow(a+this.s.heights.viewport,!1,this.s.ani));return{start:Math.floor(this.fnPixelsToRow(a,!1,this.s.ani)),end:b<c?b-1:c-1}},_fnConstruct:function(){var a=this;if(this.s.dt.oFeatures.bPaginate){this.dom.force.style.position="relative";this.dom.force.style.top="0px";this.dom.force.style.left="0px";this.dom.force.style.width="1px";this.dom.scroller=
|
||||
e("div."+this.s.dt.oClasses.sScrollBody,this.s.dt.nTableWrapper)[0];this.dom.scroller.appendChild(this.dom.force);this.dom.scroller.style.position="relative";this.dom.table=e(">table",this.dom.scroller)[0];this.dom.table.style.position="absolute";this.dom.table.style.top="0px";this.dom.table.style.left="0px";e(this.s.dt.nTableWrapper).addClass("DTS");this.s.loadingIndicator&&(this.dom.loader=e('<div class="dataTables_processing DTS_Loading">'+this.s.dt.oLanguage.sLoadingRecords+"</div>").css("display",
|
||||
"none"),e(this.dom.scroller.parentNode).css("position","relative").append(this.dom.loader));this.s.heights.row&&"auto"!=this.s.heights.row&&(this.s.autoHeight=!1);this.fnMeasure(!1);this.s.ingnoreScroll=!0;this.s.stateSaveThrottle=this.s.dt.oApi._fnThrottle(function(){a.s.dt.oApi._fnSaveState(a.s.dt)},500);e(this.dom.scroller).on("scroll.DTS",function(){a._fnScroll.call(a)});e(this.dom.scroller).on("touchstart.DTS",function(){a._fnScroll.call(a)});this.s.dt.aoDrawCallback.push({fn:function(){a.s.dt.bInitialised&&
|
||||
a._fnDrawCallback.call(a)},sName:"Scroller"});e(g).on("resize.DTS",function(){a.fnMeasure(false);a._fnInfo()});var b=!0;this.s.dt.oApi._fnCallbackReg(this.s.dt,"aoStateSaveParams",function(c,d){if(b&&a.s.dt.oLoadedState){d.iScroller=a.s.dt.oLoadedState.iScroller;d.iScrollerTopRow=a.s.dt.oLoadedState.iScrollerTopRow;b=false}else{d.iScroller=a.dom.scroller.scrollTop;d.iScrollerTopRow=a.s.topRowFloat}},"Scroller_State");this.s.dt.oLoadedState&&(this.s.topRowFloat=this.s.dt.oLoadedState.iScrollerTopRow||
|
||||
0);e(this.s.dt.nTable).one("init.dt",function(){a.fnMeasure()});this.s.dt.aoDestroyCallback.push({sName:"Scroller",fn:function(){e(g).off("resize.DTS");e(a.dom.scroller).off("touchstart.DTS scroll.DTS");e(a.s.dt.nTableWrapper).removeClass("DTS");e("div.DTS_Loading",a.dom.scroller.parentNode).remove();e(a.s.dt.nTable).off("init.dt");a.dom.table.style.position="";a.dom.table.style.top="";a.dom.table.style.left=""}})}else this.s.dt.oApi._fnLog(this.s.dt,0,"Pagination must be enabled for Scroller")},
|
||||
_fnScroll:function(){var a=this,b=this.s.heights,c=this.dom.scroller.scrollTop,d;if(!this.s.skip&&!this.s.ingnoreScroll)if(this.s.dt.bFiltered||this.s.dt.bSorted)this.s.lastScrollTop=0;else{this._fnInfo();clearTimeout(this.s.stateTO);this.s.stateTO=setTimeout(function(){a.s.dt.oApi._fnSaveState(a.s.dt)},250);if(c<this.s.redrawTop||c>this.s.redrawBottom){var f=Math.ceil((this.s.displayBuffer-1)/2*this.s.viewportRows);Math.abs(c-this.s.lastScrollTop)>b.viewport||this.s.ani?(d=parseInt(this._domain("physicalToVirtual",
|
||||
c)/b.row,10)-f,this.s.topRowFloat=this._domain("physicalToVirtual",c)/b.row):(d=this.fnPixelsToRow(c)-f,this.s.topRowFloat=this.fnPixelsToRow(c,!1));0>=d?d=0:d+this.s.dt._iDisplayLength>this.s.dt.fnRecordsDisplay()?(d=this.s.dt.fnRecordsDisplay()-this.s.dt._iDisplayLength,0>d&&(d=0)):0!==d%2&&d++;if(d!=this.s.dt._iDisplayStart&&(this.s.tableTop=e(this.s.dt.nTable).offset().top,this.s.tableBottom=e(this.s.dt.nTable).height()+this.s.tableTop,b=function(){if(a.s.scrollDrawReq===null)a.s.scrollDrawReq=
|
||||
c;a.s.dt._iDisplayStart=d;a.s.dt.oApi._fnDraw(a.s.dt)},this.s.dt.oFeatures.bServerSide?(clearTimeout(this.s.drawTO),this.s.drawTO=setTimeout(b,this.s.serverWait)):b(),this.dom.loader&&!this.s.loaderVisible))this.dom.loader.css("display","block"),this.s.loaderVisible=!0}this.s.lastScrollTop=c;this.s.stateSaveThrottle()}},_domain:function(a,b){var c=this.s.heights,d;if(c.virtual===c.scroll)return b;var e=(c.scroll-c.viewport)/2,j=(c.virtual-c.viewport)/2;d=j/(e*e);if("virtualToPhysical"===a){if(b<j)return Math.pow(b/
|
||||
d,0.5);b=2*j-b;return 0>b?c.scroll:2*e-Math.pow(b/d,0.5)}if("physicalToVirtual"===a){if(b<e)return b*b*d;b=2*e-b;return 0>b?c.virtual:2*j-b*b*d}},_fnDrawCallback:function(){var a=this,b=this.s.heights,c=this.dom.scroller.scrollTop,d=e(this.s.dt.nTable).height(),f=this.s.dt._iDisplayStart,j=this.s.dt._iDisplayLength,h=this.s.dt.fnRecordsDisplay();this.s.skip=!0;this._fnScrollForce();c=0===f?this.s.topRowFloat*b.row:f+j>=h?b.scroll-(h-this.s.topRowFloat)*b.row:this._domain("virtualToPhysical",this.s.topRowFloat*
|
||||
b.row);this.dom.scroller.scrollTop=c;this.s.baseScrollTop=c;this.s.baseRowTop=this.s.topRowFloat;var g=c-(this.s.topRowFloat-f)*b.row;0===f?g=0:f+j>=h&&(g=b.scroll-d);this.dom.table.style.top=g+"px";this.s.tableTop=g;this.s.tableBottom=d+this.s.tableTop;d=(c-this.s.tableTop)*this.s.boundaryScale;this.s.redrawTop=c-d;this.s.redrawBottom=c+d;this.s.skip=!1;this.s.dt.oFeatures.bStateSave&&null!==this.s.dt.oLoadedState&&"undefined"!=typeof this.s.dt.oLoadedState.iScroller?((c=(this.s.dt.sAjaxSource||
|
||||
a.s.dt.ajax)&&!this.s.dt.oFeatures.bServerSide?!0:!1)&&2==this.s.dt.iDraw||!c&&1==this.s.dt.iDraw)&&setTimeout(function(){e(a.dom.scroller).scrollTop(a.s.dt.oLoadedState.iScroller);a.s.redrawTop=a.s.dt.oLoadedState.iScroller-b.viewport/2;setTimeout(function(){a.s.ingnoreScroll=!1},0)},0):a.s.ingnoreScroll=!1;this.s.dt.oFeatures.bInfo&&setTimeout(function(){a._fnInfo.call(a)},0);this.dom.loader&&this.s.loaderVisible&&(this.dom.loader.css("display","none"),this.s.loaderVisible=!1)},_fnScrollForce:function(){var a=
|
||||
this.s.heights;a.virtual=a.row*this.s.dt.fnRecordsDisplay();a.scroll=a.virtual;1E6<a.scroll&&(a.scroll=1E6);this.dom.force.style.height=a.scroll>this.s.heights.row?a.scroll+"px":this.s.heights.row+"px"},_fnCalcRowHeight:function(){var a=this.s.dt,b=a.nTable,c=b.cloneNode(!1),d=e("<tbody/>").appendTo(c),f=e('<div class="'+a.oClasses.sWrapper+' DTS"><div class="'+a.oClasses.sScrollWrapper+'"><div class="'+a.oClasses.sScrollBody+'"></div></div></div>');for(e("tbody tr:lt(4)",b).clone().appendTo(d);3>
|
||||
e("tr",d).length;)d.append("<tr><td> </td></tr>");e("div."+a.oClasses.sScrollBody,f).append(c);a=this.s.dt.nHolding||b.parentNode;e(a).is(":visible")||(a="body");f.appendTo(a);this.s.heights.row=e("tr",d).eq(1).outerHeight();f.remove()},_fnInfo:function(){if(this.s.dt.oFeatures.bInfo){var a=this.s.dt,b=a.oLanguage,c=this.dom.scroller.scrollTop,d=Math.floor(this.fnPixelsToRow(c,!1,this.s.ani)+1),f=a.fnRecordsTotal(),h=a.fnRecordsDisplay(),c=Math.ceil(this.fnPixelsToRow(c+this.s.heights.viewport,
|
||||
!1,this.s.ani)),c=h<c?h:c,g=a.fnFormatNumber(d),i=a.fnFormatNumber(c),k=a.fnFormatNumber(f),l=a.fnFormatNumber(h),g=0===a.fnRecordsDisplay()&&a.fnRecordsDisplay()==a.fnRecordsTotal()?b.sInfoEmpty+b.sInfoPostFix:0===a.fnRecordsDisplay()?b.sInfoEmpty+" "+b.sInfoFiltered.replace("_MAX_",k)+b.sInfoPostFix:a.fnRecordsDisplay()==a.fnRecordsTotal()?b.sInfo.replace("_START_",g).replace("_END_",i).replace("_MAX_",k).replace("_TOTAL_",l)+b.sInfoPostFix:b.sInfo.replace("_START_",g).replace("_END_",i).replace("_MAX_",
|
||||
k).replace("_TOTAL_",l)+" "+b.sInfoFiltered.replace("_MAX_",a.fnFormatNumber(a.fnRecordsTotal()))+b.sInfoPostFix;(b=b.fnInfoCallback)&&(g=b.call(a.oInstance,a,d,c,f,h,g));a=a.aanFeatures.i;if("undefined"!=typeof a){d=0;for(f=a.length;d<f;d++)e(a[d]).html(g)}}}});h.defaults={trace:!1,rowHeight:"auto",serverWait:200,displayBuffer:9,boundaryScale:0.5,loadingIndicator:!1};h.oDefaults=h.defaults;h.version="1.4.1";"function"==typeof e.fn.dataTable&&"function"==typeof e.fn.dataTableExt.fnVersionCheck&&e.fn.dataTableExt.fnVersionCheck("1.10.0")?
|
||||
e.fn.dataTableExt.aoFeatures.push({fnInit:function(a){var b=a.oInit;new h(a,b.scroller||b.oScroller||{})},cFeature:"S",sFeature:"Scroller"}):alert("Warning: Scroller requires DataTables 1.10.0 or greater - www.datatables.net/download");e(i).on("preInit.dt.dtscroller",function(a,b){if("dt"===a.namespace){var c=b.oInit.scroller,d=m.defaults.scroller;if(c||d)d=e.extend({},c,d),!1!==c&&new h(b,d)}});e.fn.dataTable.Scroller=h;e.fn.DataTable.Scroller=h;var k=e.fn.dataTable.Api;k.register("scroller()",function(){return this});
|
||||
k.register("scroller().rowToPixels()",function(a,b,c){var d=this.context;if(d.length&&d[0].oScroller)return d[0].oScroller.fnRowToPixels(a,b,c)});k.register("scroller().pixelsToRow()",function(a,b,c){var d=this.context;if(d.length&&d[0].oScroller)return d[0].oScroller.fnPixelsToRow(a,b,c)});k.register("scroller().scrollToRow()",function(a,b){this.iterator("table",function(c){c.oScroller&&c.oScroller.fnScrollToRow(a,b)});return this});k.register("row().scrollTo()",function(a){var b=this;this.iterator("row",
|
||||
function(c,d){if(c.oScroller){var e=b.rows({order:"applied",search:"applied"}).indexes().indexOf(d);c.oScroller.fnScrollToRow(e,a)}});return this});k.register("scroller.measure()",function(a){this.iterator("table",function(b){b.oScroller&&b.oScroller.fnMeasure(a)});return this});k.register("scroller.page()",function(){var a=this.context;if(a.length&&a[0].oScroller)return a[0].oScroller.fnPageInfo()});return h});
|
||||
|
||||
Reference in New Issue
Block a user