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

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

There is a newer version: 1.2.2.1-jre17
Show newest version
(function(factory){if(typeof define==="function"&&define.amd){define(["jquery","datatables.net"],function($){return factory($,window,document)})}else if(typeof exports==="object"){module.exports=function(root,$){if(!root){root=window}if(!$||!$.fn.dataTable){$=require("datatables.net")(root,$).$}return factory($,root,root.document)}}else{factory(jQuery,window,document)}})(function($,window,document,undefined){"use strict";var DataTable=$.fn.dataTable;var Responsive=function(settings,opts){if(!DataTable.versionCheck||!DataTable.versionCheck("1.10.10")){throw"DataTables Responsive requires DataTables 1.10.10 or newer"}this.s={dt:new DataTable.Api(settings),columns:[],current:[]};if(this.s.dt.settings()[0].responsive){return}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()};$.extend(Responsive.prototype,{_constructor:function(){var that=this;var dt=this.s.dt;var dtPrivateSettings=dt.settings()[0];var oldWindowWidth=$(window).width();dt.settings()[0]._responsive=this;$(window).on("resize.dtr orientationchange.dtr",DataTable.util.throttle(function(){var width=$(window).width();if(width!==oldWindowWidth){that._resize();oldWindowWidth=width}}));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")}})}});dt.on("destroy.dtr",function(){dt.off(".dtr");$(dt.table().body()).off(".dtr");$(window).off("resize.dtr orientationchange.dtr");$.each(that.s.current,function(i,val){if(val===false){that._setColumnVis(i,true)}})});this.c.breakpoints.sort(function(a,b){return a.widthb.width?-1:0});this._classLogic();this._resizeAuto();var details=this.c.details;if(details.type!==false){that._detailsInit();dt.on("column-visibility.dtr",function(){if(that._timer){clearTimeout(that._timer)}that._timer=setTimeout(function(){that._timer=null;that._classLogic();that._resizeAuto();that._resize();that._redrawChildren()},100)});dt.on("draw.dtr",function(){that._redrawChildren()});$(dt.table().node()).addClass("dtr-"+details.type)}dt.on("column-reorder.dtr",function(e,settings,details){that._classLogic();that._resizeAuto();that._resize()});dt.on("column-sizing.dtr",function(){that._resizeAuto();that._resize()});dt.on("preXhr.dtr",function(){var rowIds=[];dt.rows().every(function(){if(this.child.isShown()){rowIds.push(this.id(true))}});dt.one("draw.dtr",function(){that._resizeAuto();that._resize();dt.rows(rowIds).every(function(){that._detailsDisplay(this,false)})})});dt.on("init.dtr",function(e,settings,details){that._resizeAuto();that._resize();if($.inArray(false,that.s.current)){dt.columns.adjust()}});this._resize()},_columnsVisiblity:function(breakpoint){var dt=this.s.dt;var columns=this.s.columns;var i,ien;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});var display=$.map(columns,function(col,i){if(dt.column(i).visible()===false){return"not-visible"}return col.auto&&col.minWidth===null?false:col.auto===true?"-":$.inArray(breakpoint,col.includeIn)!==-1});var requiredWidth=0;for(i=0,ien=display.length;i=size){add(colIdx,breakpoints[i].name)}}}else if(operator==="not-"){for(i=0,ien=breakpoints.length;i=0;i--){if(width<=breakpoints[i].width){breakpoint=breakpoints[i].name;break}}var columnsVis=this._columnsVisiblity(breakpoint);this.s.current=columnsVis;var collapsedClass=false;for(i=0,ien=columns.length;i").append(footerCells).appendTo(clonedFooter)}$("").append(headerCells).appendTo(clonedHeader);if(this.c.details.type==="inline"){$(clonedTable).addClass("dtr-inline collapsed")}$(clonedTable).find("[name]").removeAttr("name");$(clonedTable).css("position","relative");var inserted=$("
").css({width:1,height:1,overflow:"hidden",clear:"both"}).append(clonedTable);inserted.insertBefore(dt.table().node());headerCells.each(function(i){var idx=dt.column.index("fromVisible",i);columns[idx].minWidth=this.offsetWidth||0});inserted.remove()},_setColumnVis:function(col,showHide){var dt=this.s.dt;var display=showHide?"":"none";$(dt.column(col).header()).css("display",display);$(dt.column(col).footer()).css("display",display);dt.column(col).nodes().to$().css("display",display);if(!$.isEmptyObject(_childNodeStore)){dt.cells(null,col).indexes().each(function(idx){_childNodesRestore(dt,idx.row,idx.column)})}},_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]");if(typeof target==="number"){dt.cells(null,target,{page:"current"}).nodes().to$().attr("tabIndex",ctx.iTabIndex).data("dtr-keyboard",1)}else{if(target==="td:first-child, th:first-child"){target=">td:first-child, >th:first-child"}$(target,dt.rows({page:"current"}).nodes()).attr("tabIndex",ctx.iTabIndex).data("dtr-keyboard",1)}}});Responsive.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}];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()){row.child(false);$(row.node()).removeClass("parent");return false}else{row.child(render(),"child").show();$(row.node()).addClass("parent");return true}},modal:function(options){return function(row,update,render){if(!update){var close=function(){modal.remove();$(document).off("keypress.dtr")};var modal=$('
').append($('
').append($('
').append(render())).append($('
×
').click(function(){close()}))).append($('
').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("

"+options.header(row)+"

")}}}};var _childNodeStore={};function _childNodes(dt,row,col){var name=row+"-"+col;if(_childNodeStore[name]){return _childNodeStore[name]}var nodes=[];var children=dt.cell(row,col).node().childNodes;for(var i=0,ien=children.length;i');var found=false;var data=$.each(columns,function(i,col){if(col.hidden){$('
  • '+''+col.title+" "+"
  • ").append($('').append(_childNodes(api,col.rowIndex,col.columnIndex))).appendTo(ul);found=true}});return found?ul:false}},listHidden:function(){return function(api,rowIdx,columns){var data=$.map(columns,function(col){return col.hidden?'
  • '+''+col.title+" "+''+col.data+""+"
  • ":""}).join("");return data?$('
      ').append(data):false}},tableAll:function(options){options=$.extend({tableClass:""},options);return function(api,rowIdx,columns){var data=$.map(columns,function(col){return''+""+col.title+":"+" "+""+col.data+""+""}).join("");return $('').append(data)}}};Responsive.defaults={breakpoints:Responsive.breakpoints,auto:true,details:{display:Responsive.display.childRow,renderer:Responsive.renderer.listHidden(),target:0,type:"inline"},orthogonal:"display"};var Api=$.fn.dataTable.Api;Api.register("responsive()",function(){return this});Api.register("responsive.index()",function(li){li=$(li);return{column:li.data("dtr-index"),row:li.parent().data("dtr-index")}});Api.register("responsive.rebuild()",function(){return this.iterator("table",function(ctx){if(ctx._responsive){ctx._responsive._classLogic()}})});Api.register("responsive.recalc()",function(){return this.iterator("table",function(ctx){if(ctx._responsive){ctx._responsive._resizeAuto();ctx._responsive._resize()}})});Api.register("responsive.hasHidden()",function(){var ctx=this.context[0];return ctx._responsive?$.inArray(false,ctx._responsive.s.current)!==-1:false});Api.registerPlural("columns().responsiveHidden()","column().responsiveHidden()",function(){return this.iterator("column",function(settings,column){return settings._responsive?settings._responsive.s.current[column]:false},1)});Responsive.version="2.2.3";$.fn.dataTable.Responsive=Responsive;$.fn.DataTable.Responsive=Responsive;$(document).on("preInit.dt.dtr",function(e,settings,json){if(e.namespace!=="dt"){return}if($(settings.nTable).hasClass("responsive")||$(settings.nTable).hasClass("dt-responsive")||settings.oInit.responsive||DataTable.defaults.responsive){var init=settings.oInit.responsive;if(init!==false){new Responsive(settings,$.isPlainObject(init)?init:{})}}});return Responsive});