From 62e558139392cf8aeb8601eff1aab556ffccca0f Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Tue, 25 Jan 2022 12:35:46 +0000 Subject: [PATCH] c5a357ce8da2234ecd2bbd99d6fdc541253802fd Update: Alias `none` and `all` to have an optional `dtr-` prefix, to make it clear that they are responsive properties CT-1418 ccc1c01f476ca582c0250cd611724f732f7c11db Merge branch 'master' of github.com:DataTables/Responsive Sync to source repo @ccc1c01f476ca582c0250cd611724f732f7c11db --- datatables.json | 2 +- js/dataTables.responsive.js | 12 ++++--- js/dataTables.responsive.min.js | 56 ++++++++++++++++----------------- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/datatables.json b/datatables.json index 9077116..6599c75 100644 --- a/datatables.json +++ b/datatables.json @@ -9,5 +9,5 @@ ], "src-repo": "http://github.com/DataTables/Responsive", "last-tag": "2.2.9", - "last-sync": "ba72cda685dc5e8394a109355dfa7bef5dfead2d" + "last-sync": "ccc1c01f476ca582c0250cd611724f732f7c11db" } \ No newline at end of file diff --git a/js/dataTables.responsive.js b/js/dataTables.responsive.js index c4a3576..f80e833 100644 --- a/js/dataTables.responsive.js +++ b/js/dataTables.responsive.js @@ -476,7 +476,7 @@ $.extend( Responsive.prototype, { includeIn: [], auto: false, control: false, - never: className.match(/\bnever\b/) ? true : false, + never: className.match(/\b(dtr\-)?never\b/) ? true : false, priority: priority }; } ); @@ -537,7 +537,7 @@ $.extend( Responsive.prototype, { for ( var k=0, ken=classNames.length ; ktd, >th", -f).each(function(e){e=c.column.index("toData",e);!1===a.s.current[e]&&b(this).css("display","none")})});c.on("destroy.dtr",function(){c.off(".dtr");b(c.table().body()).off(".dtr");b(l).off("resize.dtr orientationchange.dtr");c.cells(".dtr-control").nodes().to$().removeClass("dtr-control");b.each(a.s.current,function(f,k){!1===k&&a._setColumnVis(f,!0)})});this.c.breakpoints.sort(function(f,k){return f.widthk.width?-1:0});this._classLogic();this._resizeAuto();d=this.c.details;!1!== -d.type&&(a._detailsInit(),c.on("column-visibility.dtr",function(){a._timer&&clearTimeout(a._timer);a._timer=setTimeout(function(){a._timer=null;a._classLogic();a._resizeAuto();a._resize(!0);a._redrawChildren()},100)}),c.on("draw.dtr",function(){a._redrawChildren()}),b(c.table().node()).addClass("dtr-"+d.type));c.on("column-reorder.dtr",function(f,k,h){a._classLogic();a._resizeAuto();a._resize(!0)});c.on("column-sizing.dtr",function(){a._resizeAuto();a._resize()});c.on("column-calc.dt",function(f, -k){f=a.s.current;for(var h=0;hh-d[q].minWidth?(r=!0,k[q]=!1):k[q]=!0,h-=d[q].minWidth)}f=!1;e=0;for(g=d.length;e=q&&f(h,c[e].name);else if("not-"===r)for(e=0,r=c.length;eg?c.columns().eq(0).length+g:g;if(c.cell(this).index().column!==k)return}k= -c.row(b(this).closest("tr"));"click"===f.type?a._detailsDisplay(k,!1):"mousedown"===f.type?b(this).css("outline","none"):"mouseup"===f.type&&b(this).trigger("blur").css("outline","")}})},_detailsObj:function(a){var c=this,d=this.s.dt;return b.map(this.s.columns,function(g,f){if(!g.never&&!g.control)return g=d.settings()[0].aoColumns[f],{className:g.sClass,columnIndex:f,data:d.cell(a,f).render(c.c.orthogonal),hidden:d.column(f).visible()&&!c.s.current[f],rowIndex:a,title:null!==g.sTitle?g.sTitle:b(d.column(f).header()).text()}})}, -_find:function(a){for(var c=this.c.breakpoints,d=0,g=c.length;d").append(h).appendTo(f)}b("").append(k).appendTo(g);"inline"===this.c.details.type&&b(d).addClass("dtr-inline collapsed");b(d).find("[name]").removeAttr("name");b(d).css("position","relative");d=b("
").css({width:1, -height:1,overflow:"hidden",clear:"both"}).append(d);d.insertBefore(a.table().node());k.each(function(e){e=a.column.index("fromVisible",e);c[e].minWidth=this.offsetWidth||0});d.remove()}},_responsiveOnlyHidden:function(){var a=this.s.dt;return b.map(this.s.current,function(c,d){return!1===a.column(d).visible()?!0:c})},_setColumnVis:function(a,c){var d=this.s.dt;c=c?"":"none";b(d.column(a).header()).css("display",c);b(d.column(a).footer()).css("display",c);d.column(a).nodes().to$().css("display",c); -b.isEmptyObject(A)||d.cells(null,a).indexes().each(function(g){y(d,g.row,g.column)})},_tabIndexes:function(){var a=this.s.dt,c=a.cells({page:"current"}).nodes().to$(),d=a.settings()[0],g=this.c.details.target;c.filter("[data-dtr-keyboard]").removeData("[data-dtr-keyboard]");"number"===typeof g?a.cells(null,g,{page:"current"}).nodes().to$().attr("tabIndex",d.iTabIndex).data("dtr-keyboard",1):("td:first-child, th:first-child"===g&&(g=">td:first-child, >th:first-child"),b(g,a.rows({page:"current"}).nodes()).attr("tabIndex", +var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(b,k,m){b instanceof String&&(b=String(b));for(var n=b.length,p=0;ptd, >th", +f).each(function(e){e=c.column.index("toData",e);!1===a.s.current[e]&&b(this).css("display","none")})});c.on("destroy.dtr",function(){c.off(".dtr");b(c.table().body()).off(".dtr");b(k).off("resize.dtr orientationchange.dtr");c.cells(".dtr-control").nodes().to$().removeClass("dtr-control");b.each(a.s.current,function(f,l){!1===l&&a._setColumnVis(f,!0)})});this.c.breakpoints.sort(function(f,l){return f.widthl.width?-1:0});this._classLogic();this._resizeAuto();d=this.c.details;!1!== +d.type&&(a._detailsInit(),c.on("column-visibility.dtr",function(){a._timer&&clearTimeout(a._timer);a._timer=setTimeout(function(){a._timer=null;a._classLogic();a._resizeAuto();a._resize(!0);a._redrawChildren()},100)}),c.on("draw.dtr",function(){a._redrawChildren()}),b(c.table().node()).addClass("dtr-"+d.type));c.on("column-reorder.dtr",function(f,l,h){a._classLogic();a._resizeAuto();a._resize(!0)});c.on("column-sizing.dtr",function(){a._resizeAuto();a._resize()});c.on("column-calc.dt",function(f, +l){f=a.s.current;for(var h=0;hh-d[q].minWidth?(r=!0,l[q]=!1):l[q]=!0,h-=d[q].minWidth)}f=!1;e=0;for(g=d.length;e=q&&f(h,c[e].name);else if("not-"===r)for(e=0,r=c.length;eg?c.columns().eq(0).length+ +g:g;if(c.cell(this).index().column!==l)return}l=c.row(b(this).closest("tr"));"click"===f.type?a._detailsDisplay(l,!1):"mousedown"===f.type?b(this).css("outline","none"):"mouseup"===f.type&&b(this).trigger("blur").css("outline","")}})},_detailsObj:function(a){var c=this,d=this.s.dt;return b.map(this.s.columns,function(g,f){if(!g.never&&!g.control)return g=d.settings()[0].aoColumns[f],{className:g.sClass,columnIndex:f,data:d.cell(a,f).render(c.c.orthogonal),hidden:d.column(f).visible()&&!c.s.current[f], +rowIndex:a,title:null!==g.sTitle?g.sTitle:b(d.column(f).header()).text()}})},_find:function(a){for(var c=this.c.breakpoints,d=0,g=c.length;d").append(h).appendTo(f)}b("").append(l).appendTo(g);"inline"===this.c.details.type&&b(d).addClass("dtr-inline collapsed");b(d).find("[name]").removeAttr("name");b(d).css("position", +"relative");d=b("
").css({width:1,height:1,overflow:"hidden",clear:"both"}).append(d);d.insertBefore(a.table().node());l.each(function(e){e=a.column.index("fromVisible",e);c[e].minWidth=this.offsetWidth||0});d.remove()}},_responsiveOnlyHidden:function(){var a=this.s.dt;return b.map(this.s.current,function(c,d){return!1===a.column(d).visible()?!0:c})},_setColumnVis:function(a,c){var d=this.s.dt;c=c?"":"none";b(d.column(a).header()).css("display",c);b(d.column(a).footer()).css("display",c);d.column(a).nodes().to$().css("display", +c);b.isEmptyObject(A)||d.cells(null,a).indexes().each(function(g){y(d,g.row,g.column)})},_tabIndexes:function(){var a=this.s.dt,c=a.cells({page:"current"}).nodes().to$(),d=a.settings()[0],g=this.c.details.target;c.filter("[data-dtr-keyboard]").removeData("[data-dtr-keyboard]");"number"===typeof g?a.cells(null,g,{page:"current"}).nodes().to$().attr("tabIndex",d.iTabIndex).data("dtr-keyboard",1):("td:first-child, th:first-child"===g&&(g=">td:first-child, >th:first-child"),b(g,a.rows({page:"current"}).nodes()).attr("tabIndex", d.iTabIndex).data("dtr-keyboard",1))}});u.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}];u.display={childRow:function(a,c,d){if(c){if(b(a.node()).hasClass("parent"))return a.child(d(),"child").show(),!0}else{if(a.child.isShown())return a.child(!1),b(a.node()).removeClass("parent"),!1;a.child(d(),"child").show();b(a.node()).addClass("parent");return!0}},childRowImmediate:function(a,c,d){if(!c&& -a.child.isShown()||!a.responsive.hasHidden())return a.child(!1),b(a.node()).removeClass("parent"),!1;a.child(d(),"child").show();b(a.node()).addClass("parent");return!0},modal:function(a){return function(c,d,g){if(d)b("div.dtr-modal-content").empty().append(g());else{var f=function(){k.remove();b(m).off("keypress.dtr")},k=b('
').append(b('
').append(b('
').append(g())).append(b('
×
').click(function(){f()}))).append(b('
').click(function(){f()})).appendTo("body"); -b(m).on("keyup.dtr",function(h){27===h.keyCode&&(h.stopPropagation(),f())})}a&&a.header&&b("div.dtr-modal-content").prepend("

"+a.header(c)+"

")}}};var A={};u.renderer={listHiddenNodes:function(){return function(a,c,d){var g=b('
    '),f=!1;b.each(d,function(k,h){h.hidden&&(b("
  • '+ +a.child.isShown()||!a.responsive.hasHidden())return a.child(!1),b(a.node()).removeClass("parent"),!1;a.child(d(),"child").show();b(a.node()).addClass("parent");return!0},modal:function(a){return function(c,d,g){if(d)b("div.dtr-modal-content").empty().append(g());else{var f=function(){l.remove();b(m).off("keypress.dtr")},l=b('
    ').append(b('
    ').append(b('
    ').append(g())).append(b('
    ×
    ').click(function(){f()}))).append(b('
    ').click(function(){f()})).appendTo("body"); +b(m).on("keyup.dtr",function(h){27===h.keyCode&&(h.stopPropagation(),f())})}a&&a.header&&b("div.dtr-modal-content").prepend("

    "+a.header(c)+"

    ")}}};var A={};u.renderer={listHiddenNodes:function(){return function(a,c,d){var g=b('
      '),f=!1;b.each(d,function(l,h){h.hidden&&(b("
    • '+ h.title+"
    • ").append(b('').append(p(a,h.rowIndex,h.columnIndex))).appendTo(g),f=!0)});return f?g:!1}},listHidden:function(){return function(a,c,d){return(a=b.map(d,function(g){var f=g.className?'class="'+g.className+'"':"";return g.hidden?"
    • '+g.title+' '+g.data+"
    • ":""}).join(""))?b('
        ').append(a):!1}},tableAll:function(a){a=b.extend({tableClass:""},a);return function(c,d,g){c=b.map(g,function(f){return"'+f.title+": "+f.data+""}).join("");return b('').append(c)}}};u.defaults={breakpoints:u.breakpoints,auto:!0,details:{display:u.display.childRow,renderer:u.renderer.listHidden(), target:0,type:"inline"},orthogonal:"display"};var C=b.fn.dataTable.Api;C.register("responsive()",function(){return this});C.register("responsive.index()",function(a){a=b(a);return{column:a.data("dtr-index"),row:a.parent().data("dtr-index")}});C.register("responsive.rebuild()",function(){return this.iterator("table",function(a){a._responsive&&a._responsive._classLogic()})});C.register("responsive.recalc()",function(){return this.iterator("table",function(a){a._responsive&&(a._responsive._resizeAuto(),