diff --git a/datatables.json b/datatables.json index 2652e0a..3b29b87 100644 --- a/datatables.json +++ b/datatables.json @@ -11,5 +11,5 @@ ], "src-repo": "http://github.com/DataTables/Responsive", "last-tag": "3.0.3", - "last-sync": "f0d38e6f1e3405f2e626eec16263186c79855aa3" + "last-sync": "079d776d2c7eaf9f0131b195d41da7afccc8e3dd" } \ No newline at end of file diff --git a/js/dataTables.responsive.js b/js/dataTables.responsive.js index 110832b..b98758c 100644 --- a/js/dataTables.responsive.js +++ b/js/dataTables.responsive.js @@ -743,11 +743,15 @@ $.extend(Responsive.prototype, { .filter('.dtr-control') .removeClass('dtr-control'); - dt.cells(null, firstVisible, { page: 'current' }) - .nodes() - .to$() - .addClass('dtr-control'); + if (firstVisible >= 0) { + dt.cells(null, firstVisible, { page: 'current' }) + .nodes() + .to$() + .addClass('dtr-control'); + } } + + this._tabIndexes(); }, /** @@ -814,12 +818,6 @@ $.extend(Responsive.prototype, { details.target = 'td.dtr-control, th.dtr-control'; } - // 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(); @@ -1370,7 +1368,12 @@ $.extend(Responsive.prototype, { target = '>td:first-child, >th:first-child'; } - $(target, dt.rows({ page: 'current' }).nodes()) + var rows = dt.rows({ page: 'current' }).nodes(); + var nodes = target === 'tr' + ? $(rows) + : $(target, rows); + + nodes .attr('tabIndex', ctx.iTabIndex) .data('dtr-keyboard', 1); } diff --git a/js/dataTables.responsive.min.js b/js/dataTables.responsive.min.js index bfcfdab..c40c38b 100644 --- a/js/dataTables.responsive.min.js +++ b/js/dataTables.responsive.min.js @@ -1,4 +1,4 @@ /*! Responsive 3.0.3 * © SpryMedia Ltd - datatables.net/license */ -!function(n){var i,r;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return n(e,window,document)}):"object"==typeof exports?(i=require("jquery"),r=function(e,t){t.fn.dataTable||require("datatables.net")(e,t)},"undefined"==typeof window?module.exports=function(e,t){return e=e||window,t=t||i(e),r(e,t),n(t,e,e.document)}:(r(window,i),module.exports=n(i,window,window.document))):n(jQuery,window,document)}(function(b,y,d){"use strict";function a(e,t){if(!i.versionCheck||!i.versionCheck("2"))throw"DataTables Responsive requires DataTables 2 or newer";this.s={childNodeStore:{},columns:[],current:[],dt:new i.Api(e)},this.s.dt.settings()[0].responsive||(t&&"string"==typeof t.details?t.details={type:t.details}:t&&!1===t.details?t.details={type:!1}:t&&!0===t.details&&(t.details={type:"inline"}),this.c=b.extend(!0,{},a.defaults,i.defaults.responsive,t),(e.responsive=this)._constructor())}var i=b.fn.dataTable,e=(b.extend(a.prototype,{_constructor:function(){var s=this,r=this.s.dt,t=b(y).innerWidth(),e=(r.settings()[0]._responsive=this,b(y).on("orientationchange.dtr",i.util.throttle(function(){var e=b(y).innerWidth();e!==t&&(s._resize(),t=e)})),r.on("row-created.dtr",function(e,t,n,i){-1!==b.inArray(!1,s.s.current)&&b(">td, >th",t).each(function(e){e=r.column.index("toData",e);!1===s.s.current[e]&&b(this).css("display","none").addClass("dtr-hidden")})}),r.on("destroy.dtr",function(){r.off(".dtr"),b(r.table().body()).off(".dtr"),b(y).off("resize.dtr orientationchange.dtr"),r.cells(".dtr-control").nodes().to$().removeClass("dtr-control"),b(r.table().node()).removeClass("dtr-inline collapsed"),b.each(s.s.current,function(e,t){!1===t&&s._setColumnVis(e,!0)})}),this.c.breakpoints.sort(function(e,t){return e.widtht.width?-1:0}),this._classLogic(),this.c.details);!1!==e.type&&(s._detailsInit(),r.on("column-visibility.dtr",function(){s._timer&&clearTimeout(s._timer),s._timer=setTimeout(function(){s._timer=null,s._classLogic(),s._resizeAuto(),s._resize(!0),s._redrawChildren()},100)}),r.on("draw.dtr",function(){s._redrawChildren()}),b(r.table().node()).addClass("dtr-"+e.type)),r.on("column-calc.dt",function(e,t){for(var n=s.s.current,i=0;i=r&&u(e,l[s].name);else if("not-"===n)for(s=0,o=l.length;s{e=e.filter(function(e){return!!e}).map(function(e){return b(e.cell).clone(!1).css("display","table-cell").css("width","auto").css("min-width",0)});b("").append(e).appendTo(i)}),b("").appendTo(d)),l=0;l");this.c.details.renderer._responsiveMovesNodes?t.rows({page:"current"}).every(function(n){var i,e=this.node();e&&(i=e.cloneNode(!1),t.cells(n,s).every(function(e,t){t=r.s.childNodeStore[n+"-"+t];(t?b(this.node().cloneNode(!1)).append(b(t).clone()):b(this.node()).clone(!1)).appendTo(i)}),d.append(i))}):b(d).append(b(t.rows({page:"current"}).nodes()).clone(!1)).find("th, td").css("display",""),d.find("th, td").css("display",""),t.table().footer.structure(s).forEach(e=>{e=e.filter(function(e){return!!e}).map(function(e){return b(e.cell).clone(!1).css("display","table-cell").css("width","auto").css("min-width",0)});b("").append(e).appendTo(o)}),"inline"===this.c.details.type&&b(e).addClass("dtr-inline collapsed"),b(e).find("[name]").removeAttr("name"),b(e).css("position","relative");e=b("
").css({width:1,height:1,overflow:"hidden",clear:"both"}).append(e);e.insertBefore(t.table().node()),a.children().each(function(e){e=t.column.index("fromVisible",e);n[e].minWidth=this.offsetWidth||0}),e.remove()}},_responsiveOnlyHidden:function(){var n=this.s.dt;return b.map(this.s.current,function(e,t){return!1===n.column(t).visible()||e})},_setColumnVis:function(e,t){var n=this,i=this.s.dt,r=t?"":"none";this._setHeaderVis(e,t,i.table().header.structure()),this._setHeaderVis(e,t,i.table().footer.structure()),i.column(e).nodes().to$().css("display",r).toggleClass("dtr-hidden",!t),b.isEmptyObject(this.s.childNodeStore)||i.cells(null,e).indexes().each(function(e){n._childNodesRestore(i,e.row,e.column)})},_setHeaderVis:function(n,i,e){var r=this,s=i?"":"none";e.forEach(function(e){if(e[n])b(e[n].cell).css("display",s).toggleClass("dtr-hidden",!i);else for(var t=n;0<=t;){if(e[t]){e[t].cell.colSpan=r._colspan(e,t);break}t--}})},_colspan:function(e,t){for(var n=1,i=t+1;itd:first-child, >th:first-child":i,e.rows({page:"current"}).nodes())).attr("tabIndex",n.iTabIndex).data("dtr-keyboard",1)}}),a.defaults={breakpoints:a.breakpoints=[{name:"desktop",width:1/0},{name:"tablet-l",width:1024},{name:"tablet-p",width:768},{name:"mobile-l",width:480},{name:"mobile-p",width:320}],auto:!0,details:{display:(a.display={childRow:function(e,t,n){var i=b(e.node());return t?i.hasClass("dtr-expanded")?(e.child(n(),"child").show(),!0):void 0:i.hasClass("dtr-expanded")?(e.child(!1),!1):!1!==(t=n())&&(e.child(t,"child").show(),!0)},childRowImmediate:function(e,t,n){var i=b(e.node());return!t&&i.hasClass("dtr-expanded")||!e.responsive.hasHidden()?(e.child(!1),!1):!1!==(t=n())&&(e.child(t,"child").show(),!0)},modal:function(o){return function(e,t,n,i){n=n();if(!1===n)return!1;if(t){if(!(s=b("div.dtr-modal-content")).length||e.index()!==s.data("dtr-row-idx"))return null;s.empty().append(n)}else{var r=function(){s.remove(),b(d).off("keypress.dtr"),b(e.node()).removeClass("dtr-expanded"),i()},s=b('
').append(b('
').append(b('
').data("dtr-row-idx",e.index()).append(n)).append(b('
×
').click(function(){r()}))).append(b('
').click(function(){r()})).appendTo("body");b(e.node()).addClass("dtr-expanded"),b(d).on("keyup.dtr",function(e){27===e.keyCode&&(e.stopPropagation(),r())})}return o&&o.header&&b("div.dtr-modal-content").prepend("

"+o.header(e)+"

"),!0}}}).childRow,renderer:(a.renderer={listHiddenNodes:function(){function e(i,e,t){var r=this,s=b('
    '),o=!1;return b.each(t,function(e,t){var n;t.hidden&&(n=t.className?'class="'+t.className+'"':"",b("
  • '+t.title+"
  • ").append(b('').append(r._childNodes(i,t.rowIndex,t.columnIndex))).appendTo(s),o=!0)}),!!o&&s}return e._responsiveMovesNodes=!0,e},listHidden:function(){return function(e,t,n){n=b.map(n,function(e){var t=e.className?'class="'+e.className+'"':"";return e.hidden?"
  • '+e.title+' '+e.data+"
  • ":""}).join("");return!!n&&b('
      ').append(n)}},tableAll:function(i){return i=b.extend({tableClass:""},i),function(e,t,n){n=b.map(n,function(e){return"'+e.title+": "+e.data+""}).join("");return b('').append(n)}}}).listHidden(),target:0,type:"inline"},orthogonal:"display"},b.fn.dataTable.Api);return e.register("responsive()",function(){return this}),e.register("responsive.index()",function(e){return{column:(e=b(e)).data("dtr-index"),row:e.parent().data("dtr-index")}}),e.register("responsive.rebuild()",function(){return this.iterator("table",function(e){e._responsive&&e._responsive._classLogic()})}),e.register("responsive.recalc()",function(){return this.iterator("table",function(e){e._responsive&&(e._responsive._resizeAuto(),e._responsive._resize())})}),e.register("responsive.hasHidden()",function(){var e=this.context[0];return!!e._responsive&&-1!==b.inArray(!1,e._responsive._responsiveOnlyHidden())}),e.registerPlural("columns().responsiveHidden()","column().responsiveHidden()",function(){return this.iterator("column",function(e,t){return!!e._responsive&&e._responsive._responsiveOnlyHidden()[t]},1)}),a.version="3.0.3",b.fn.dataTable.Responsive=a,b.fn.DataTable.Responsive=a,b(d).on("preInit.dt.dtr",function(e,t,n){"dt"===e.namespace&&(b(t.nTable).hasClass("responsive")||b(t.nTable).hasClass("dt-responsive")||t.oInit.responsive||i.defaults.responsive)&&!1!==(e=t.oInit.responsive)&&new a(t,b.isPlainObject(e)?e:{})}),i}); \ No newline at end of file +!function(n){var i,r;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(e){return n(e,window,document)}):"object"==typeof exports?(i=require("jquery"),r=function(e,t){t.fn.dataTable||require("datatables.net")(e,t)},"undefined"==typeof window?module.exports=function(e,t){return e=e||window,t=t||i(e),r(e,t),n(t,e,e.document)}:(r(window,i),module.exports=n(i,window,window.document))):n(jQuery,window,document)}(function(b,y,d){"use strict";function a(e,t){if(!i.versionCheck||!i.versionCheck("2"))throw"DataTables Responsive requires DataTables 2 or newer";this.s={childNodeStore:{},columns:[],current:[],dt:new i.Api(e)},this.s.dt.settings()[0].responsive||(t&&"string"==typeof t.details?t.details={type:t.details}:t&&!1===t.details?t.details={type:!1}:t&&!0===t.details&&(t.details={type:"inline"}),this.c=b.extend(!0,{},a.defaults,i.defaults.responsive,t),(e.responsive=this)._constructor())}var i=b.fn.dataTable,e=(b.extend(a.prototype,{_constructor:function(){var s=this,r=this.s.dt,t=b(y).innerWidth(),e=(r.settings()[0]._responsive=this,b(y).on("orientationchange.dtr",i.util.throttle(function(){var e=b(y).innerWidth();e!==t&&(s._resize(),t=e)})),r.on("row-created.dtr",function(e,t,n,i){-1!==b.inArray(!1,s.s.current)&&b(">td, >th",t).each(function(e){e=r.column.index("toData",e);!1===s.s.current[e]&&b(this).css("display","none").addClass("dtr-hidden")})}),r.on("destroy.dtr",function(){r.off(".dtr"),b(r.table().body()).off(".dtr"),b(y).off("resize.dtr orientationchange.dtr"),r.cells(".dtr-control").nodes().to$().removeClass("dtr-control"),b(r.table().node()).removeClass("dtr-inline collapsed"),b.each(s.s.current,function(e,t){!1===t&&s._setColumnVis(e,!0)})}),this.c.breakpoints.sort(function(e,t){return e.widtht.width?-1:0}),this._classLogic(),this.c.details);!1!==e.type&&(s._detailsInit(),r.on("column-visibility.dtr",function(){s._timer&&clearTimeout(s._timer),s._timer=setTimeout(function(){s._timer=null,s._classLogic(),s._resizeAuto(),s._resize(!0),s._redrawChildren()},100)}),r.on("draw.dtr",function(){s._redrawChildren()}),b(r.table().node()).addClass("dtr-"+e.type)),r.on("column-calc.dt",function(e,t){for(var n=s.s.current,i=0;i=r&&u(e,l[s].name);else if("not-"===n)for(s=0,o=l.length;s{e=e.filter(function(e){return!!e}).map(function(e){return b(e.cell).clone(!1).css("display","table-cell").css("width","auto").css("min-width",0)});b("").append(e).appendTo(i)}),b("").appendTo(d)),l=0;l");this.c.details.renderer._responsiveMovesNodes?t.rows({page:"current"}).every(function(n){var i,e=this.node();e&&(i=e.cloneNode(!1),t.cells(n,s).every(function(e,t){t=r.s.childNodeStore[n+"-"+t];(t?b(this.node().cloneNode(!1)).append(b(t).clone()):b(this.node()).clone(!1)).appendTo(i)}),d.append(i))}):b(d).append(b(t.rows({page:"current"}).nodes()).clone(!1)).find("th, td").css("display",""),d.find("th, td").css("display",""),t.table().footer.structure(s).forEach(e=>{e=e.filter(function(e){return!!e}).map(function(e){return b(e.cell).clone(!1).css("display","table-cell").css("width","auto").css("min-width",0)});b("").append(e).appendTo(o)}),"inline"===this.c.details.type&&b(e).addClass("dtr-inline collapsed"),b(e).find("[name]").removeAttr("name"),b(e).css("position","relative");e=b("
      ").css({width:1,height:1,overflow:"hidden",clear:"both"}).append(e);e.insertBefore(t.table().node()),a.children().each(function(e){e=t.column.index("fromVisible",e);n[e].minWidth=this.offsetWidth||0}),e.remove()}},_responsiveOnlyHidden:function(){var n=this.s.dt;return b.map(this.s.current,function(e,t){return!1===n.column(t).visible()||e})},_setColumnVis:function(e,t){var n=this,i=this.s.dt,r=t?"":"none";this._setHeaderVis(e,t,i.table().header.structure()),this._setHeaderVis(e,t,i.table().footer.structure()),i.column(e).nodes().to$().css("display",r).toggleClass("dtr-hidden",!t),b.isEmptyObject(this.s.childNodeStore)||i.cells(null,e).indexes().each(function(e){n._childNodesRestore(i,e.row,e.column)})},_setHeaderVis:function(n,i,e){var r=this,s=i?"":"none";e.forEach(function(e){if(e[n])b(e[n].cell).css("display",s).toggleClass("dtr-hidden",!i);else for(var t=n;0<=t;){if(e[t]){e[t].cell.colSpan=r._colspan(e,t);break}t--}})},_colspan:function(e,t){for(var n=1,i=t+1;itd:first-child, >th:first-child"),t=e.rows({page:"current"}).nodes(),"tr"===i?b(t):b(i,t))).attr("tabIndex",n.iTabIndex).data("dtr-keyboard",1)}}),a.defaults={breakpoints:a.breakpoints=[{name:"desktop",width:1/0},{name:"tablet-l",width:1024},{name:"tablet-p",width:768},{name:"mobile-l",width:480},{name:"mobile-p",width:320}],auto:!0,details:{display:(a.display={childRow:function(e,t,n){var i=b(e.node());return t?i.hasClass("dtr-expanded")?(e.child(n(),"child").show(),!0):void 0:i.hasClass("dtr-expanded")?(e.child(!1),!1):!1!==(t=n())&&(e.child(t,"child").show(),!0)},childRowImmediate:function(e,t,n){var i=b(e.node());return!t&&i.hasClass("dtr-expanded")||!e.responsive.hasHidden()?(e.child(!1),!1):!1!==(t=n())&&(e.child(t,"child").show(),!0)},modal:function(o){return function(e,t,n,i){n=n();if(!1===n)return!1;if(t){if(!(s=b("div.dtr-modal-content")).length||e.index()!==s.data("dtr-row-idx"))return null;s.empty().append(n)}else{var r=function(){s.remove(),b(d).off("keypress.dtr"),b(e.node()).removeClass("dtr-expanded"),i()},s=b('
      ').append(b('
      ').append(b('
      ').data("dtr-row-idx",e.index()).append(n)).append(b('
      ×
      ').click(function(){r()}))).append(b('
      ').click(function(){r()})).appendTo("body");b(e.node()).addClass("dtr-expanded"),b(d).on("keyup.dtr",function(e){27===e.keyCode&&(e.stopPropagation(),r())})}return o&&o.header&&b("div.dtr-modal-content").prepend("

      "+o.header(e)+"

      "),!0}}}).childRow,renderer:(a.renderer={listHiddenNodes:function(){function e(i,e,t){var r=this,s=b('
        '),o=!1;return b.each(t,function(e,t){var n;t.hidden&&(n=t.className?'class="'+t.className+'"':"",b("
      • '+t.title+"
      • ").append(b('').append(r._childNodes(i,t.rowIndex,t.columnIndex))).appendTo(s),o=!0)}),!!o&&s}return e._responsiveMovesNodes=!0,e},listHidden:function(){return function(e,t,n){n=b.map(n,function(e){var t=e.className?'class="'+e.className+'"':"";return e.hidden?"
      • '+e.title+' '+e.data+"
      • ":""}).join("");return!!n&&b('
          ').append(n)}},tableAll:function(i){return i=b.extend({tableClass:""},i),function(e,t,n){n=b.map(n,function(e){return"
      "}).join("");return b('
      '+e.title+": "+e.data+"
      ').append(n)}}}).listHidden(),target:0,type:"inline"},orthogonal:"display"},b.fn.dataTable.Api);return e.register("responsive()",function(){return this}),e.register("responsive.index()",function(e){return{column:(e=b(e)).data("dtr-index"),row:e.parent().data("dtr-index")}}),e.register("responsive.rebuild()",function(){return this.iterator("table",function(e){e._responsive&&e._responsive._classLogic()})}),e.register("responsive.recalc()",function(){return this.iterator("table",function(e){e._responsive&&(e._responsive._resizeAuto(),e._responsive._resize())})}),e.register("responsive.hasHidden()",function(){var e=this.context[0];return!!e._responsive&&-1!==b.inArray(!1,e._responsive._responsiveOnlyHidden())}),e.registerPlural("columns().responsiveHidden()","column().responsiveHidden()",function(){return this.iterator("column",function(e,t){return!!e._responsive&&e._responsive._responsiveOnlyHidden()[t]},1)}),a.version="3.0.3",b.fn.dataTable.Responsive=a,b.fn.DataTable.Responsive=a,b(d).on("preInit.dt.dtr",function(e,t,n){"dt"===e.namespace&&(b(t.nTable).hasClass("responsive")||b(t.nTable).hasClass("dt-responsive")||t.oInit.responsive||i.defaults.responsive)&&!1!==(e=t.oInit.responsive)&&new a(t,b.isPlainObject(e)?e:{})}),i}); \ No newline at end of file diff --git a/js/dataTables.responsive.min.mjs b/js/dataTables.responsive.min.mjs index e9ce3f3..e0b54cd 100644 --- a/js/dataTables.responsive.min.mjs +++ b/js/dataTables.responsive.min.mjs @@ -1,4 +1,4 @@ /*! Responsive 3.0.3 * © SpryMedia Ltd - datatables.net/license */ -import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;var Responsive=function(e,t){if(!DataTable.versionCheck||!DataTable.versionCheck("2"))throw"DataTables Responsive requires DataTables 2 or newer";this.s={childNodeStore:{},columns:[],current:[],dt:new DataTable.Api(e)},this.s.dt.settings()[0].responsive||(t&&"string"==typeof t.details?t.details={type:t.details}:t&&!1===t.details?t.details={type:!1}:t&&!0===t.details&&(t.details={type:"inline"}),this.c=$.extend(!0,{},Responsive.defaults,DataTable.defaults.responsive,t),(e.responsive=this)._constructor())},Api=($.extend(Responsive.prototype,{_constructor:function(){var s=this,r=this.s.dt,t=$(window).innerWidth(),e=(r.settings()[0]._responsive=this,$(window).on("orientationchange.dtr",DataTable.util.throttle(function(){var e=$(window).innerWidth();e!==t&&(s._resize(),t=e)})),r.on("row-created.dtr",function(e,t,n,i){-1!==$.inArray(!1,s.s.current)&&$(">td, >th",t).each(function(e){e=r.column.index("toData",e);!1===s.s.current[e]&&$(this).css("display","none").addClass("dtr-hidden")})}),r.on("destroy.dtr",function(){r.off(".dtr"),$(r.table().body()).off(".dtr"),$(window).off("resize.dtr orientationchange.dtr"),r.cells(".dtr-control").nodes().to$().removeClass("dtr-control"),$(r.table().node()).removeClass("dtr-inline collapsed"),$.each(s.s.current,function(e,t){!1===t&&s._setColumnVis(e,!0)})}),this.c.breakpoints.sort(function(e,t){return e.widtht.width?-1:0}),this._classLogic(),this.c.details);!1!==e.type&&(s._detailsInit(),r.on("column-visibility.dtr",function(){s._timer&&clearTimeout(s._timer),s._timer=setTimeout(function(){s._timer=null,s._classLogic(),s._resizeAuto(),s._resize(!0),s._redrawChildren()},100)}),r.on("draw.dtr",function(){s._redrawChildren()}),$(r.table().node()).addClass("dtr-"+e.type)),r.on("column-calc.dt",function(e,t){for(var n=s.s.current,i=0;i=r&&u(e,l[s].name);else if("not-"===n)for(s=0,o=l.length;s{e=e.filter(function(e){return!!e}).map(function(e){return $(e.cell).clone(!1).css("display","table-cell").css("width","auto").css("min-width",0)});$("").append(e).appendTo(i)}),$("").appendTo(d)),l=0;l");this.c.details.renderer._responsiveMovesNodes?t.rows({page:"current"}).every(function(n){var i,e=this.node();e&&(i=e.cloneNode(!1),t.cells(n,s).every(function(e,t){t=r.s.childNodeStore[n+"-"+t];(t?$(this.node().cloneNode(!1)).append($(t).clone()):$(this.node()).clone(!1)).appendTo(i)}),d.append(i))}):$(d).append($(t.rows({page:"current"}).nodes()).clone(!1)).find("th, td").css("display",""),d.find("th, td").css("display",""),t.table().footer.structure(s).forEach(e=>{e=e.filter(function(e){return!!e}).map(function(e){return $(e.cell).clone(!1).css("display","table-cell").css("width","auto").css("min-width",0)});$("").append(e).appendTo(o)}),"inline"===this.c.details.type&&$(e).addClass("dtr-inline collapsed"),$(e).find("[name]").removeAttr("name"),$(e).css("position","relative");e=$("
      ").css({width:1,height:1,overflow:"hidden",clear:"both"}).append(e);e.insertBefore(t.table().node()),a.children().each(function(e){e=t.column.index("fromVisible",e);n[e].minWidth=this.offsetWidth||0}),e.remove()}},_responsiveOnlyHidden:function(){var n=this.s.dt;return $.map(this.s.current,function(e,t){return!1===n.column(t).visible()||e})},_setColumnVis:function(e,t){var n=this,i=this.s.dt,r=t?"":"none";this._setHeaderVis(e,t,i.table().header.structure()),this._setHeaderVis(e,t,i.table().footer.structure()),i.column(e).nodes().to$().css("display",r).toggleClass("dtr-hidden",!t),$.isEmptyObject(this.s.childNodeStore)||i.cells(null,e).indexes().each(function(e){n._childNodesRestore(i,e.row,e.column)})},_setHeaderVis:function(n,i,e){var r=this,s=i?"":"none";e.forEach(function(e){if(e[n])$(e[n].cell).css("display",s).toggleClass("dtr-hidden",!i);else for(var t=n;0<=t;){if(e[t]){e[t].cell.colSpan=r._colspan(e,t);break}t--}})},_colspan:function(e,t){for(var n=1,i=t+1;itd:first-child, >th:first-child"),$(i,e.rows({page:"current"}).nodes()))).attr("tabIndex",n.iTabIndex).data("dtr-keyboard",1)}}),Responsive.breakpoints=[{name:"desktop",width:1/0},{name:"tablet-l",width:1024},{name:"tablet-p",width:768},{name:"mobile-l",width:480},{name:"mobile-p",width:320}],Responsive.display={childRow:function(e,t,n){var i=$(e.node());return t?i.hasClass("dtr-expanded")?(e.child(n(),"child").show(),!0):void 0:i.hasClass("dtr-expanded")?(e.child(!1),!1):!1!==(t=n())&&(e.child(t,"child").show(),!0)},childRowImmediate:function(e,t,n){var i=$(e.node());return!t&&i.hasClass("dtr-expanded")||!e.responsive.hasHidden()?(e.child(!1),!1):!1!==(t=n())&&(e.child(t,"child").show(),!0)},modal:function(o){return function(e,t,n,i){n=n();if(!1===n)return!1;if(t){if(!(s=$("div.dtr-modal-content")).length||e.index()!==s.data("dtr-row-idx"))return null;s.empty().append(n)}else{function r(){s.remove(),$(document).off("keypress.dtr"),$(e.node()).removeClass("dtr-expanded"),i()}var s=$('
      ').append($('
      ').append($('
      ').data("dtr-row-idx",e.index()).append(n)).append($('
      ×
      ').click(function(){r()}))).append($('
      ').click(function(){r()})).appendTo("body");$(e.node()).addClass("dtr-expanded"),$(document).on("keyup.dtr",function(e){27===e.keyCode&&(e.stopPropagation(),r())})}return o&&o.header&&$("div.dtr-modal-content").prepend("

      "+o.header(e)+"

      "),!0}}},Responsive.renderer={listHiddenNodes:function(){function e(i,e,t){var r=this,s=$('
        '),o=!1;return $.each(t,function(e,t){var n;t.hidden&&(n=t.className?'class="'+t.className+'"':"",$("
      • '+t.title+"
      • ").append($('').append(r._childNodes(i,t.rowIndex,t.columnIndex))).appendTo(s),o=!0)}),!!o&&s}return e._responsiveMovesNodes=!0,e},listHidden:function(){return function(e,t,n){n=$.map(n,function(e){var t=e.className?'class="'+e.className+'"':"";return e.hidden?"
      • '+e.title+' '+e.data+"
      • ":""}).join("");return!!n&&$('
          ').append(n)}},tableAll:function(i){return i=$.extend({tableClass:""},i),function(e,t,n){n=$.map(n,function(e){return"
      "}).join("");return $('
      '+e.title+": "+e.data+"
      ').append(n)}}},Responsive.defaults={breakpoints:Responsive.breakpoints,auto:!0,details:{display:Responsive.display.childRow,renderer:Responsive.renderer.listHidden(),target:0,type:"inline"},orthogonal:"display"},$.fn.dataTable.Api);Api.register("responsive()",function(){return this}),Api.register("responsive.index()",function(e){return{column:(e=$(e)).data("dtr-index"),row:e.parent().data("dtr-index")}}),Api.register("responsive.rebuild()",function(){return this.iterator("table",function(e){e._responsive&&e._responsive._classLogic()})}),Api.register("responsive.recalc()",function(){return this.iterator("table",function(e){e._responsive&&(e._responsive._resizeAuto(),e._responsive._resize())})}),Api.register("responsive.hasHidden()",function(){var e=this.context[0];return!!e._responsive&&-1!==$.inArray(!1,e._responsive._responsiveOnlyHidden())}),Api.registerPlural("columns().responsiveHidden()","column().responsiveHidden()",function(){return this.iterator("column",function(e,t){return!!e._responsive&&e._responsive._responsiveOnlyHidden()[t]},1)}),Responsive.version="3.0.3",$.fn.dataTable.Responsive=Responsive,$.fn.DataTable.Responsive=Responsive,$(document).on("preInit.dt.dtr",function(e,t,n){"dt"===e.namespace&&($(t.nTable).hasClass("responsive")||$(t.nTable).hasClass("dt-responsive")||t.oInit.responsive||DataTable.defaults.responsive)&&!1!==(e=t.oInit.responsive)&&new Responsive(t,$.isPlainObject(e)?e:{})});export default DataTable; \ No newline at end of file +import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;var Responsive=function(e,t){if(!DataTable.versionCheck||!DataTable.versionCheck("2"))throw"DataTables Responsive requires DataTables 2 or newer";this.s={childNodeStore:{},columns:[],current:[],dt:new DataTable.Api(e)},this.s.dt.settings()[0].responsive||(t&&"string"==typeof t.details?t.details={type:t.details}:t&&!1===t.details?t.details={type:!1}:t&&!0===t.details&&(t.details={type:"inline"}),this.c=$.extend(!0,{},Responsive.defaults,DataTable.defaults.responsive,t),(e.responsive=this)._constructor())},Api=($.extend(Responsive.prototype,{_constructor:function(){var s=this,r=this.s.dt,t=$(window).innerWidth(),e=(r.settings()[0]._responsive=this,$(window).on("orientationchange.dtr",DataTable.util.throttle(function(){var e=$(window).innerWidth();e!==t&&(s._resize(),t=e)})),r.on("row-created.dtr",function(e,t,n,i){-1!==$.inArray(!1,s.s.current)&&$(">td, >th",t).each(function(e){e=r.column.index("toData",e);!1===s.s.current[e]&&$(this).css("display","none").addClass("dtr-hidden")})}),r.on("destroy.dtr",function(){r.off(".dtr"),$(r.table().body()).off(".dtr"),$(window).off("resize.dtr orientationchange.dtr"),r.cells(".dtr-control").nodes().to$().removeClass("dtr-control"),$(r.table().node()).removeClass("dtr-inline collapsed"),$.each(s.s.current,function(e,t){!1===t&&s._setColumnVis(e,!0)})}),this.c.breakpoints.sort(function(e,t){return e.widtht.width?-1:0}),this._classLogic(),this.c.details);!1!==e.type&&(s._detailsInit(),r.on("column-visibility.dtr",function(){s._timer&&clearTimeout(s._timer),s._timer=setTimeout(function(){s._timer=null,s._classLogic(),s._resizeAuto(),s._resize(!0),s._redrawChildren()},100)}),r.on("draw.dtr",function(){s._redrawChildren()}),$(r.table().node()).addClass("dtr-"+e.type)),r.on("column-calc.dt",function(e,t){for(var n=s.s.current,i=0;i=r&&u(e,l[s].name);else if("not-"===n)for(s=0,o=l.length;s{e=e.filter(function(e){return!!e}).map(function(e){return $(e.cell).clone(!1).css("display","table-cell").css("width","auto").css("min-width",0)});$("").append(e).appendTo(i)}),$("").appendTo(d)),l=0;l");this.c.details.renderer._responsiveMovesNodes?t.rows({page:"current"}).every(function(n){var i,e=this.node();e&&(i=e.cloneNode(!1),t.cells(n,s).every(function(e,t){t=r.s.childNodeStore[n+"-"+t];(t?$(this.node().cloneNode(!1)).append($(t).clone()):$(this.node()).clone(!1)).appendTo(i)}),d.append(i))}):$(d).append($(t.rows({page:"current"}).nodes()).clone(!1)).find("th, td").css("display",""),d.find("th, td").css("display",""),t.table().footer.structure(s).forEach(e=>{e=e.filter(function(e){return!!e}).map(function(e){return $(e.cell).clone(!1).css("display","table-cell").css("width","auto").css("min-width",0)});$("").append(e).appendTo(o)}),"inline"===this.c.details.type&&$(e).addClass("dtr-inline collapsed"),$(e).find("[name]").removeAttr("name"),$(e).css("position","relative");e=$("
      ").css({width:1,height:1,overflow:"hidden",clear:"both"}).append(e);e.insertBefore(t.table().node()),a.children().each(function(e){e=t.column.index("fromVisible",e);n[e].minWidth=this.offsetWidth||0}),e.remove()}},_responsiveOnlyHidden:function(){var n=this.s.dt;return $.map(this.s.current,function(e,t){return!1===n.column(t).visible()||e})},_setColumnVis:function(e,t){var n=this,i=this.s.dt,r=t?"":"none";this._setHeaderVis(e,t,i.table().header.structure()),this._setHeaderVis(e,t,i.table().footer.structure()),i.column(e).nodes().to$().css("display",r).toggleClass("dtr-hidden",!t),$.isEmptyObject(this.s.childNodeStore)||i.cells(null,e).indexes().each(function(e){n._childNodesRestore(i,e.row,e.column)})},_setHeaderVis:function(n,i,e){var r=this,s=i?"":"none";e.forEach(function(e){if(e[n])$(e[n].cell).css("display",s).toggleClass("dtr-hidden",!i);else for(var t=n;0<=t;){if(e[t]){e[t].cell.colSpan=r._colspan(e,t);break}t--}})},_colspan:function(e,t){for(var n=1,i=t+1;itd:first-child, >th:first-child"),t=e.rows({page:"current"}).nodes(),"tr"===i?$(t):$(i,t))).attr("tabIndex",n.iTabIndex).data("dtr-keyboard",1)}}),Responsive.breakpoints=[{name:"desktop",width:1/0},{name:"tablet-l",width:1024},{name:"tablet-p",width:768},{name:"mobile-l",width:480},{name:"mobile-p",width:320}],Responsive.display={childRow:function(e,t,n){var i=$(e.node());return t?i.hasClass("dtr-expanded")?(e.child(n(),"child").show(),!0):void 0:i.hasClass("dtr-expanded")?(e.child(!1),!1):!1!==(t=n())&&(e.child(t,"child").show(),!0)},childRowImmediate:function(e,t,n){var i=$(e.node());return!t&&i.hasClass("dtr-expanded")||!e.responsive.hasHidden()?(e.child(!1),!1):!1!==(t=n())&&(e.child(t,"child").show(),!0)},modal:function(o){return function(e,t,n,i){n=n();if(!1===n)return!1;if(t){if(!(s=$("div.dtr-modal-content")).length||e.index()!==s.data("dtr-row-idx"))return null;s.empty().append(n)}else{function r(){s.remove(),$(document).off("keypress.dtr"),$(e.node()).removeClass("dtr-expanded"),i()}var s=$('
      ').append($('
      ').append($('
      ').data("dtr-row-idx",e.index()).append(n)).append($('
      ×
      ').click(function(){r()}))).append($('
      ').click(function(){r()})).appendTo("body");$(e.node()).addClass("dtr-expanded"),$(document).on("keyup.dtr",function(e){27===e.keyCode&&(e.stopPropagation(),r())})}return o&&o.header&&$("div.dtr-modal-content").prepend("

      "+o.header(e)+"

      "),!0}}},Responsive.renderer={listHiddenNodes:function(){function e(i,e,t){var r=this,s=$('
        '),o=!1;return $.each(t,function(e,t){var n;t.hidden&&(n=t.className?'class="'+t.className+'"':"",$("
      • '+t.title+"
      • ").append($('').append(r._childNodes(i,t.rowIndex,t.columnIndex))).appendTo(s),o=!0)}),!!o&&s}return e._responsiveMovesNodes=!0,e},listHidden:function(){return function(e,t,n){n=$.map(n,function(e){var t=e.className?'class="'+e.className+'"':"";return e.hidden?"
      • '+e.title+' '+e.data+"
      • ":""}).join("");return!!n&&$('
          ').append(n)}},tableAll:function(i){return i=$.extend({tableClass:""},i),function(e,t,n){n=$.map(n,function(e){return"
      "}).join("");return $('
      '+e.title+": "+e.data+"
      ').append(n)}}},Responsive.defaults={breakpoints:Responsive.breakpoints,auto:!0,details:{display:Responsive.display.childRow,renderer:Responsive.renderer.listHidden(),target:0,type:"inline"},orthogonal:"display"},$.fn.dataTable.Api);Api.register("responsive()",function(){return this}),Api.register("responsive.index()",function(e){return{column:(e=$(e)).data("dtr-index"),row:e.parent().data("dtr-index")}}),Api.register("responsive.rebuild()",function(){return this.iterator("table",function(e){e._responsive&&e._responsive._classLogic()})}),Api.register("responsive.recalc()",function(){return this.iterator("table",function(e){e._responsive&&(e._responsive._resizeAuto(),e._responsive._resize())})}),Api.register("responsive.hasHidden()",function(){var e=this.context[0];return!!e._responsive&&-1!==$.inArray(!1,e._responsive._responsiveOnlyHidden())}),Api.registerPlural("columns().responsiveHidden()","column().responsiveHidden()",function(){return this.iterator("column",function(e,t){return!!e._responsive&&e._responsive._responsiveOnlyHidden()[t]},1)}),Responsive.version="3.0.3",$.fn.dataTable.Responsive=Responsive,$.fn.DataTable.Responsive=Responsive,$(document).on("preInit.dt.dtr",function(e,t,n){"dt"===e.namespace&&($(t.nTable).hasClass("responsive")||$(t.nTable).hasClass("dt-responsive")||t.oInit.responsive||DataTable.defaults.responsive)&&!1!==(e=t.oInit.responsive)&&new Responsive(t,$.isPlainObject(e)?e:{})});export default DataTable; \ No newline at end of file diff --git a/js/dataTables.responsive.mjs b/js/dataTables.responsive.mjs index cb2aabd..f792539 100644 --- a/js/dataTables.responsive.mjs +++ b/js/dataTables.responsive.mjs @@ -703,11 +703,15 @@ $.extend(Responsive.prototype, { .filter('.dtr-control') .removeClass('dtr-control'); - dt.cells(null, firstVisible, { page: 'current' }) - .nodes() - .to$() - .addClass('dtr-control'); + if (firstVisible >= 0) { + dt.cells(null, firstVisible, { page: 'current' }) + .nodes() + .to$() + .addClass('dtr-control'); + } } + + this._tabIndexes(); }, /** @@ -774,12 +778,6 @@ $.extend(Responsive.prototype, { details.target = 'td.dtr-control, th.dtr-control'; } - // 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(); @@ -1330,7 +1328,12 @@ $.extend(Responsive.prototype, { target = '>td:first-child, >th:first-child'; } - $(target, dt.rows({ page: 'current' }).nodes()) + var rows = dt.rows({ page: 'current' }).nodes(); + var nodes = target === 'tr' + ? $(rows) + : $(target, rows); + + nodes .attr('tabIndex', ctx.iTabIndex) .data('dtr-keyboard', 1); }