datatables.net-autofill 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! AutoFill 3.0.
|
|
1
|
+
/*! AutoFill 3.0.1 for DataTables
|
|
2
2
|
* Copyright (c) SpryMedia Ltd - datatables.net/license
|
|
3
3
|
*/
|
|
4
4
|
|
|
@@ -939,7 +939,7 @@ AutoFill.defaults = {
|
|
|
939
939
|
horizontal: true
|
|
940
940
|
};
|
|
941
941
|
/** AutoFill version */
|
|
942
|
-
AutoFill.version = '3.0.
|
|
942
|
+
AutoFill.version = '3.0.1';
|
|
943
943
|
|
|
944
944
|
// Doesn't do anything - Not documented
|
|
945
945
|
Api.register('autoFill()', function () {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! AutoFill 3.0.
|
|
1
|
+
/*! AutoFill 3.0.1 for DataTables
|
|
2
2
|
* Copyright (c) SpryMedia Ltd - datatables.net/license
|
|
3
3
|
*/
|
|
4
|
-
(e=>{var o;"function"==typeof define&&define.amd?define(["datatables.net"],function(t){return e(window,document,t)}):"object"==typeof exports?(o=function(t){t.DataTable||require("datatables.net")(t)},"undefined"==typeof window?module.exports=function(t){return t=t||window,o(t),e(t,t.document,t.DataTable)}:(o(window),module.exports=e(window,window.document,window.DataTable))):e(window,document,window.DataTable)})(function(c,n,u){var h=u.Dom,t=u.Api,d=u.util;if(!u||!u.versionCheck||!u.versionCheck("3"))throw"Warning: AutoFill requires DataTables 3 or greater";var o=0;class r{enabled(){return this.s.enabled}enable(t=!0){let e=this;var o=this.s.namespace;if(!1===t)return this.disable();this.s.enabled=!0,this._focusListener(),this.dom.handle.on("mousedown touchstart",function(t){return e._mousedown(t),!1});function i(){e.s.handle={height:0,width:0},e.dom.handle.css({height:"",width:""}),e.dom.attachedTo&&e._attach(e.dom.attachedTo)}return h.w.on("resize"+o,function(){0<h.s("div.dtaf-handle").count()&&e.dom.attachedTo&&e._attach(e.dom.attachedTo)}),h.w.on("orientationchange"+o,function(){setTimeout(function(){i(),setTimeout(i,150)},50)}),this}disable(){return this.s.enabled=!1,this._focusListenerRemove(),this}constructor(t,e){this.c=d.object.assignDeep({},r.defaults,e),this.s={dt:new u.Api(t),enabled:!1,end:{column:0,row:0},handle:{height:0,width:0},namespace:".autoFill"+o++,scroll:{windowHeight:0,windowWidth:0,dtTop:0,dtLeft:0,dtHeight:0,dtWidth:0},scrollInterval:null,start:{column:0,row:0}},this.dom={attachedTo:null,container:h.c("div").classAdd("dtaf-container"),closeButton:h.c("button").classAdd(r.classes.close).html("×"),dtScroll:null,handle:h.c("div").classAdd("dtaf-handle"),list:h.c("div").classAdd("dtaf-list").html(this.s.dt.i18n("autoFill.info","")).attr("aria-modal",!0).attr("role","dialog").append(h.c("div").classAdd("dtaf-list-items")),offsetParent:null,start:null,select:{top:h.c("div").classAdd("dtaf-select top"),right:h.c("div").classAdd("dtaf-select right"),bottom:h.c("div").classAdd("dtaf-select bottom"),left:h.c("div").classAdd("dtaf-select left")}},this.dom.list.appendTo(this.dom.container),this._init()}_init(){var t=this.s.dt,e=h.s(this.s.dt.table().container()).find("div.dt-scroll-body");t.settings()[0].autoFill=this,e.count()&&"static"===(this.dom.dtScroll=e).css("position")&&e.css("position","relative"),!1!==this.c.enable&&this.enable(),t.on("destroy.autoFill",()=>{this._focusListenerRemove(),this.dom.handle.off()})}_attach(t){var e=this.s.dt,o=e.cell(t).index(),i=this.dom.handle,l=this.s.handle;o&&-1!==e.columns(this.c.columns).indexes().indexOf(o.column)?(this.dom.offsetParent||(this.dom.offsetParent=e.table().node().offsetParent),l.height&&l.width||(i.appendTo("body"),l.height=i.height("outer"),l.width=i.width("outer")),o=this._getPosition(t,this.dom.offsetParent),this.dom.attachedTo=t,i.css({top:o.top+t.offsetHeight-l.height+"px",left:o.left+t.offsetWidth-l.width+"px"}).appendTo(this.dom.offsetParent)):this._detach()}_actionSelector(o){let i=this,l=this.s.dt,n=r.actions,s=[];if(d.object.each(n,function(t,e){e.available(l,o)&&s.push(t)}),1===s.length&&!1===this.c.alwaysAsk){var t=n[s[0]].execute(l,o,null);this._update(t,o)}else if(1<s.length||this.c.alwaysAsk){var a=this.dom.list.children("div.dtaf-list-items").empty();s.push("cancel");for(let t=0;t<s.length;t++){let e=s[t];a.append(h.c("button").classAdd(r.classes.btn).html(n[e].option(l,o)).append(h.c("span").classAdd("dtaf-button").html(l.i18n("autoFill.button",""))).on("click",function(t){"button"===t.target.nodeName.toLowerCase()&&(t=n[e].execute(l,o,h.s(this).closest("button")),i._update(t,o),i.dom.container.remove())}))}this.dom.container.appendTo("body"),this.dom.container.on("click",function(t){t.target===i.dom.container.get(0)&&i.dom.container.remove()}),this.c.closeButton&&(this.dom.list.prepend(this.dom.closeButton).classAdd(r.classes.closeable),this.dom.closeButton.on("click",function(){return i.dom.container.trigger("click")}))}}_detach(){this.dom.attachedTo=null,this.dom.handle.detach()}_drawSelection(t,e){var o,i=this.s.dt,l=this.s.start,n=h.s(this.dom.start),t={row:this.c.vertical?i.rows({page:"current"}).nodes().indexOf(t.parentNode):l.row,column:this.c.horizontal?h.s(t).index():l.column},s=i.column.index("toData",t.column),a=i.row(":eq("+t.row+")",{page:"current"}),a=h.s(i.cell(a.index(),s).node());i.cell(a.get(0)).any()&&-1!==i.columns(this.c.columns).indexes().indexOf(s)&&-1!==t.row&&(this.s.end=t,i=l.row<t.row?n:a,s=l.row<t.row?a:n,o=l.column<t.column?n:a,l=l.column<t.column?a:n,i=this._getPosition(i.get(0)).top,o=this._getPosition(o.get(0)).left,t=this._getPosition(s.get(0)).top+s.height("outer")-i,a=this._getPosition(l.get(0)).left+l.width("outer")-o,(n=this.dom.select).top.css({top:i+"px",left:o+"px",width:a+"px"}),n.left.css({top:i+"px",left:o+"px",height:t+"px"}),n.bottom.css({top:i+t+"px",left:o+"px",width:a+"px"}),n.right.css({top:i+"px",left:o+a+"px",height:t+"px"}))}_editor(l){var n=this.s.dt;let s=this.c.editor;if(s){var a={},d=[],c=s.fields();for(let i=0,t=l.length;i<t;i++)for(let t=0,e=l[i].length;t<e;t++){var r=l[i][t],u=n.settings()[0].columns[r.index.column];let o=u.editField;if(void 0===o){var h=u.data;for(let t=0,e=c.length;t<e;t++){var f=s.field(c[t]);if(f.dataSrc()===h){o=f.name();break}}}if(!o)throw"Could not automatically determine field data. Please see https://datatables.net/tn/11";if("string"!=typeof o)throw"AutoFill with multiple edit fields is not supported";a[o]||(a[o]={});u=n.row(r.index.row).id();a[o][u]=r.set,d.push(r.index)}s.bubble(d,!1).multiSet(a).submit(null,function(){s.close()})}}_emitEvent(t,e){this.s.dt.trigger(t,e)}_focusListener(){var i=this,e=this.s.dt,t=this.s.namespace,o=null!==this.c.focus?this.c.focus:e.init().keys||e.settings()[0].keytable?"focus":"hover";"focus"===o?e.on("key-focus.autoFill",function(t,e,o){i._attach(o.node())}).on("key-blur.autoFill",function(t,e,o){i._detach()}):"click"===o?(h.s(e.table().body()).on("click"+t,"td, th",function(t){i._attach(this)}),h.s(n.body).on("click"+t,function(t){h.s(t.target).closest(e.table().body()).count()||i._detach()})):h.s(e.table().body()).on("mouseenter"+t+" touchstart"+t,"td, th",function(t){i._attach(this)}).on("mouseleave"+t+"touchend"+t,function(t){h.s(t.relatedTarget).classHas("dtaf-handle")||i._detach()})}_focusListenerRemove(){var t=this.s.namespace,e=this.s.dt;e.off(".autoFill"),h.s(e.table().body()).off(t),h.s(n.body).off(t),h.w.off(t)}_getPosition(t,e){let o=h.s(this.s.dt.table().node().offsetParent),i=t,l,n=0,s=0;e&&(o=h.s(e));do{var a=i.offsetTop,d=i.offsetLeft;if(l=h.s(i.offsetParent),n+=a+ +parseInt(l.css("border-top-width")||"0"),s+=d+ +parseInt(l.css("border-left-width")||"0"),"body"===i.nodeName.toLowerCase())break}while(i=l.get(0),l.get(0)!==o.get(0));return{top:n,left:s}}_mousedown(t){let e=this;var o=this.s.dt,i=(this.dom.start=this.dom.attachedTo,this.s.start={row:o.rows({page:"current"}).nodes().indexOf(h.s(this.dom.start).parent().get(0)),column:h.s(this.dom.start).index()},h.s(n.body).on("mousemove.autoFill touchmove.autoFill",function(t){e._mousemove(t),"touchmove"===t.type&&h.s(n.body).one("touchend.autoFill",function(){e._detach()})}).on("mouseup.autoFill touchend.autoFill",function(t){e._mouseup(t)}),this.dom.select),o=o.table().node().offsetParent,i=(i.top.appendTo(o),i.left.appendTo(o),i.right.appendTo(o),i.bottom.appendTo(o),this._drawSelection(this.dom.start,t),this.dom.handle.css("display","none"),this.dom.dtScroll);this.s.scroll={windowHeight:c.innerHeight,windowWidth:c.innerWidth,dtTop:i?i.offset().top:0,dtLeft:i?i.offset().left:0,dtHeight:i?i.height("outer"):0,dtWidth:i?i.width("outer"):0}}_mousemove(t){var e=t.touches&&t.touches.length?n.elementFromPoint(t.touches[0].clientX,t.touches[0].clientY):t.target,o=e.nodeName.toLowerCase();"td"!==o&&"th"!==o||(this._drawSelection(e,t),this._shiftScroll(t))}_mouseup(e){h.s(n.body).off(".autoFill");let o=this,d=this.s.dt;var t=this.dom.select,t=(t.top.remove(),t.left.remove(),t.right.remove(),t.bottom.remove(),this.dom.handle.css("display","block"),this.s.start),i=this.s.end;if(t.row!==i.row||t.column!==i.column){var l=d.cell(":eq("+t.row+")",t.column+":visible",{page:"current"});if(h.s(l.node()).find("div.DTE").count()){let t=d.editor();t.on("submitSuccess.dtaf close.dtaf",function(){t.off(".dtaf"),setTimeout(function(){o._mouseup(e)},100)}).on("submitComplete.dtaf preSubmitCancelled.dtaf close.dtaf",function(){t.off(".dtaf")}),void t.submit()}else{let n=this._range(t.row,i.row);var c=this._range(t.column,i.column),r=[];let s=d.settings()[0].columns,a=d.columns(this.c.columns).indexes();for(let l=0;l<n.length;l++)r.push(c.map(function(t){var e=d.row(":eq("+n[l]+")",{page:"current"}),e=d.cell(e.index(),t+":visible");let o=e.data();var t=e.index(),i=s[t.column].editField;if(void 0!==i&&(o=u.util.get(i)(d.row(t.row).data())),-1!==a.indexOf(t.column))return{cell:e,data:o,label:e.data(),index:t}}).filter(t=>!!t));this._actionSelector(r),this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null)}}}_range(t,e){var o,i=[];if(t<=e)for(o=t;o<=e;o++)i.push(o);else for(o=t;e<=o;o--)i.push(o);return i}_shiftScroll(t){var e,o,i,l,n=this,s=this.s.scroll,a=!1,d=t.type.includes("touch")?t.touches[0].clientX:t.pageX-c.scrollX,t=t.type.includes("touch")?t.touches[0].clientY:t.pageY-c.scrollY;t<65?e=-5:t>s.windowHeight-65&&(e=5),d<65?o=-5:d>s.windowWidth-65&&(o=5),null!==s.dtTop&&t<s.dtTop+65?i=-5:null!==s.dtTop&&t>s.dtTop+s.dtHeight-65&&(i=5),null!==s.dtLeft&&d<s.dtLeft+65?l=-5:null!==s.dtLeft&&d>s.dtLeft+s.dtWidth-65&&(l=5),e||o||i||l?(s.windowVert=e,s.windowHoriz=o,s.dtVert=i,s.dtHoriz=l,a=!0):this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null),!this.s.scrollInterval&&a&&(this.s.scrollInterval=setInterval(function(){var t;c.scrollTo(c.scrollX+(s.windowHoriz||0),c.scrollY+(s.windowVert||0)),(s.dtVert||s.dtHoriz)&&((t=null==(t=n.dom.dtScroll)?void 0:t.get(0))&&s.dtVert&&(t.scrollTop+=s.dtVert),t)&&s.dtHoriz&&(t.scrollLeft+=s.dtHoriz)},20))}_update(t,i){if(!1!==t){var l,t=this.s.dt,n=t.columns(this.c.columns).indexes(),e=(this._emitEvent("preAutoFill",[t,i]),this._editor(i),null!==this.c.update?this.c.update:!this.c.editor);if(e){for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)l=i[o][t],-1!==n.indexOf(l.index.column)&&l.cell.data(l.set);t.draw(!1)}this._emitEvent("autoFill",[t,i])}}}return r.actions={increment:{available:function(t,e){e=e[0][0].label;return!isNaN(e-parseFloat(e))},option:function(t,e){return t.i18n("autoFill.increment",'Increment / decrement each cell by: <input type="number" value="1">')},execute:function(t,i,e){let l=+i[0][0].data;var n=e?parseFloat(e.find("input").val()):1;for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=l,l+=n}},fill:{available:function(t,e){return!0},option:function(t,e){return t.i18n("autoFill.fill","Fill all cells with <i>%d</i>",e[0][0].label)},execute:function(t,i,e){var l=i[0][0].data;for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=l}},fillHorizontal:{available:function(t,e){return 1<e.length&&1<e[0].length},option:function(t,e){return t.i18n("autoFill.fillHorizontal","Fill cells horizontally")},execute:function(t,i,e){for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=i[o][0].data}},fillVertical:{available:function(t,e){return 1<e.length&&1<e[0].length},option:function(t,e){return t.i18n("autoFill.fillVertical","Fill cells vertically")},execute:function(t,i,e){for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=i[0][t].data}},cancel:{available:function(){return!1},option:function(t){return t.i18n("autoFill.cancel","Cancel")},execute:function(){return!1}}},r.classes={btn:"btn",close:"dtaf-list-close",closeable:"dtaf-list-closeable"},r.defaults={alwaysAsk:!1,closeButton:!0,focus:null,columns:"",enable:!0,update:!0,editor:null,vertical:!0,horizontal:!0},r.version="3.0.0",t.register("autoFill()",function(){return this.inst(this.context)}),t.register("autoFill().enabled()",function(){var t=this.context[0];return!!t.autoFill&&t.autoFill.enabled()}),t.register("autoFill().enable()",function(e){return this.iterator("table",function(t){t.autoFill&&t.autoFill.enable(e)})}),t.register("autoFill().disable()",function(){return this.iterator("table",function(t){t.autoFill&&t.autoFill.disable()})}),h.s(n).on("preInit.dt.autofill",function(t,e){var o,i;"dt"===t.namespace&&(t=e.init.autoFill,o=u.defaults.autoFill,t||o)&&(i={},d.is.plainObject(o)&&d.object.assign(i,o),d.is.plainObject(t)&&d.object.assign(i,t),!1!==t)&&new r(e,i)}),u.AutoFill=r,u});
|
|
4
|
+
(e=>{var o;"function"==typeof define&&define.amd?define(["datatables.net"],function(t){return e(window,document,t)}):"object"==typeof exports?(o=function(t){t.DataTable||require("datatables.net")(t)},"undefined"==typeof window?module.exports=function(t){return t=t||window,o(t),e(t,t.document,t.DataTable)}:(o(window),module.exports=e(window,window.document,window.DataTable))):e(window,document,window.DataTable)})(function(c,n,u){var h=u.Dom,t=u.Api,d=u.util;if(!u||!u.versionCheck||!u.versionCheck("3"))throw"Warning: AutoFill requires DataTables 3 or greater";var o=0;class r{enabled(){return this.s.enabled}enable(t=!0){let e=this;var o=this.s.namespace;if(!1===t)return this.disable();this.s.enabled=!0,this._focusListener(),this.dom.handle.on("mousedown touchstart",function(t){return e._mousedown(t),!1});function i(){e.s.handle={height:0,width:0},e.dom.handle.css({height:"",width:""}),e.dom.attachedTo&&e._attach(e.dom.attachedTo)}return h.w.on("resize"+o,function(){0<h.s("div.dtaf-handle").count()&&e.dom.attachedTo&&e._attach(e.dom.attachedTo)}),h.w.on("orientationchange"+o,function(){setTimeout(function(){i(),setTimeout(i,150)},50)}),this}disable(){return this.s.enabled=!1,this._focusListenerRemove(),this}constructor(t,e){this.c=d.object.assignDeep({},r.defaults,e),this.s={dt:new u.Api(t),enabled:!1,end:{column:0,row:0},handle:{height:0,width:0},namespace:".autoFill"+o++,scroll:{windowHeight:0,windowWidth:0,dtTop:0,dtLeft:0,dtHeight:0,dtWidth:0},scrollInterval:null,start:{column:0,row:0}},this.dom={attachedTo:null,container:h.c("div").classAdd("dtaf-container"),closeButton:h.c("button").classAdd(r.classes.close).html("×"),dtScroll:null,handle:h.c("div").classAdd("dtaf-handle"),list:h.c("div").classAdd("dtaf-list").html(this.s.dt.i18n("autoFill.info","")).attr("aria-modal",!0).attr("role","dialog").append(h.c("div").classAdd("dtaf-list-items")),offsetParent:null,start:null,select:{top:h.c("div").classAdd("dtaf-select top"),right:h.c("div").classAdd("dtaf-select right"),bottom:h.c("div").classAdd("dtaf-select bottom"),left:h.c("div").classAdd("dtaf-select left")}},this.dom.list.appendTo(this.dom.container),this._init()}_init(){var t=this.s.dt,e=h.s(this.s.dt.table().container()).find("div.dt-scroll-body");t.settings()[0].autoFill=this,e.count()&&"static"===(this.dom.dtScroll=e).css("position")&&e.css("position","relative"),!1!==this.c.enable&&this.enable(),t.on("destroy.autoFill",()=>{this._focusListenerRemove(),this.dom.handle.off()})}_attach(t){var e=this.s.dt,o=e.cell(t).index(),i=this.dom.handle,l=this.s.handle;o&&-1!==e.columns(this.c.columns).indexes().indexOf(o.column)?(this.dom.offsetParent||(this.dom.offsetParent=e.table().node().offsetParent),l.height&&l.width||(i.appendTo("body"),l.height=i.height("outer"),l.width=i.width("outer")),o=this._getPosition(t,this.dom.offsetParent),this.dom.attachedTo=t,i.css({top:o.top+t.offsetHeight-l.height+"px",left:o.left+t.offsetWidth-l.width+"px"}).appendTo(this.dom.offsetParent)):this._detach()}_actionSelector(o){let i=this,l=this.s.dt,n=r.actions,s=[];if(d.object.each(n,function(t,e){e.available(l,o)&&s.push(t)}),1===s.length&&!1===this.c.alwaysAsk){var t=n[s[0]].execute(l,o,null);this._update(t,o)}else if(1<s.length||this.c.alwaysAsk){var a=this.dom.list.children("div.dtaf-list-items").empty();s.push("cancel");for(let t=0;t<s.length;t++){let e=s[t];a.append(h.c("button").classAdd(r.classes.btn).html(n[e].option(l,o)).append(h.c("span").classAdd("dtaf-button").html(l.i18n("autoFill.button",""))).on("click",function(t){"button"===t.target.nodeName.toLowerCase()&&(t=n[e].execute(l,o,h.s(this).closest("button")),i._update(t,o),i.dom.container.remove())}))}this.dom.container.appendTo("body"),this.dom.container.on("click",function(t){t.target===i.dom.container.get(0)&&i.dom.container.remove()}),this.c.closeButton&&(this.dom.list.prepend(this.dom.closeButton).classAdd(r.classes.closeable),this.dom.closeButton.on("click",function(){return i.dom.container.trigger("click")}))}}_detach(){this.dom.attachedTo=null,this.dom.handle.detach()}_drawSelection(t,e){var o,i=this.s.dt,l=this.s.start,n=h.s(this.dom.start),t={row:this.c.vertical?i.rows({page:"current"}).nodes().indexOf(t.parentNode):l.row,column:this.c.horizontal?h.s(t).index():l.column},s=i.column.index("toData",t.column),a=i.row(":eq("+t.row+")",{page:"current"}),a=h.s(i.cell(a.index(),s).node());i.cell(a.get(0)).any()&&-1!==i.columns(this.c.columns).indexes().indexOf(s)&&-1!==t.row&&(this.s.end=t,i=l.row<t.row?n:a,s=l.row<t.row?a:n,o=l.column<t.column?n:a,l=l.column<t.column?a:n,i=this._getPosition(i.get(0)).top,o=this._getPosition(o.get(0)).left,t=this._getPosition(s.get(0)).top+s.height("outer")-i,a=this._getPosition(l.get(0)).left+l.width("outer")-o,(n=this.dom.select).top.css({top:i+"px",left:o+"px",width:a+"px"}),n.left.css({top:i+"px",left:o+"px",height:t+"px"}),n.bottom.css({top:i+t+"px",left:o+"px",width:a+"px"}),n.right.css({top:i+"px",left:o+a+"px",height:t+"px"}))}_editor(l){var n=this.s.dt;let s=this.c.editor;if(s){var a={},d=[],c=s.fields();for(let i=0,t=l.length;i<t;i++)for(let t=0,e=l[i].length;t<e;t++){var r=l[i][t],u=n.settings()[0].columns[r.index.column];let o=u.editField;if(void 0===o){var h=u.data;for(let t=0,e=c.length;t<e;t++){var f=s.field(c[t]);if(f.dataSrc()===h){o=f.name();break}}}if(!o)throw"Could not automatically determine field data. Please see https://datatables.net/tn/11";if("string"!=typeof o)throw"AutoFill with multiple edit fields is not supported";a[o]||(a[o]={});u=n.row(r.index.row).id();a[o][u]=r.set,d.push(r.index)}s.bubble(d,!1).multiSet(a).submit(null,function(){s.close()})}}_emitEvent(t,e){this.s.dt.trigger(t,e)}_focusListener(){var i=this,e=this.s.dt,t=this.s.namespace,o=null!==this.c.focus?this.c.focus:e.init().keys||e.settings()[0].keytable?"focus":"hover";"focus"===o?e.on("key-focus.autoFill",function(t,e,o){i._attach(o.node())}).on("key-blur.autoFill",function(t,e,o){i._detach()}):"click"===o?(h.s(e.table().body()).on("click"+t,"td, th",function(t){i._attach(this)}),h.s(n.body).on("click"+t,function(t){h.s(t.target).closest(e.table().body()).count()||i._detach()})):h.s(e.table().body()).on("mouseenter"+t+" touchstart"+t,"td, th",function(t){i._attach(this)}).on("mouseleave"+t+"touchend"+t,function(t){h.s(t.relatedTarget).classHas("dtaf-handle")||i._detach()})}_focusListenerRemove(){var t=this.s.namespace,e=this.s.dt;e.off(".autoFill"),h.s(e.table().body()).off(t),h.s(n.body).off(t),h.w.off(t)}_getPosition(t,e){let o=h.s(this.s.dt.table().node().offsetParent),i=t,l,n=0,s=0;e&&(o=h.s(e));do{var a=i.offsetTop,d=i.offsetLeft;if(l=h.s(i.offsetParent),n+=a+ +parseInt(l.css("border-top-width")||"0"),s+=d+ +parseInt(l.css("border-left-width")||"0"),"body"===i.nodeName.toLowerCase())break}while(i=l.get(0),l.get(0)!==o.get(0));return{top:n,left:s}}_mousedown(t){let e=this;var o=this.s.dt,i=(this.dom.start=this.dom.attachedTo,this.s.start={row:o.rows({page:"current"}).nodes().indexOf(h.s(this.dom.start).parent().get(0)),column:h.s(this.dom.start).index()},h.s(n.body).on("mousemove.autoFill touchmove.autoFill",function(t){e._mousemove(t),"touchmove"===t.type&&h.s(n.body).one("touchend.autoFill",function(){e._detach()})}).on("mouseup.autoFill touchend.autoFill",function(t){e._mouseup(t)}),this.dom.select),o=o.table().node().offsetParent,i=(i.top.appendTo(o),i.left.appendTo(o),i.right.appendTo(o),i.bottom.appendTo(o),this._drawSelection(this.dom.start,t),this.dom.handle.css("display","none"),this.dom.dtScroll);this.s.scroll={windowHeight:c.innerHeight,windowWidth:c.innerWidth,dtTop:i?i.offset().top:0,dtLeft:i?i.offset().left:0,dtHeight:i?i.height("outer"):0,dtWidth:i?i.width("outer"):0}}_mousemove(t){var e=t.touches&&t.touches.length?n.elementFromPoint(t.touches[0].clientX,t.touches[0].clientY):t.target,o=e.nodeName.toLowerCase();"td"!==o&&"th"!==o||(this._drawSelection(e,t),this._shiftScroll(t))}_mouseup(e){h.s(n.body).off(".autoFill");let o=this,d=this.s.dt;var t=this.dom.select,t=(t.top.remove(),t.left.remove(),t.right.remove(),t.bottom.remove(),this.dom.handle.css("display","block"),this.s.start),i=this.s.end;if(t.row!==i.row||t.column!==i.column){var l=d.cell(":eq("+t.row+")",t.column+":visible",{page:"current"});if(h.s(l.node()).find("div.DTE").count()){let t=d.editor();t.on("submitSuccess.dtaf close.dtaf",function(){t.off(".dtaf"),setTimeout(function(){o._mouseup(e)},100)}).on("submitComplete.dtaf preSubmitCancelled.dtaf close.dtaf",function(){t.off(".dtaf")}),void t.submit()}else{let n=this._range(t.row,i.row);var c=this._range(t.column,i.column),r=[];let s=d.settings()[0].columns,a=d.columns(this.c.columns).indexes();for(let l=0;l<n.length;l++)r.push(c.map(function(t){var e=d.row(":eq("+n[l]+")",{page:"current"}),e=d.cell(e.index(),t+":visible");let o=e.data();var t=e.index(),i=s[t.column].editField;if(void 0!==i&&(o=u.util.get(i)(d.row(t.row).data())),-1!==a.indexOf(t.column))return{cell:e,data:o,label:e.data(),index:t}}).filter(t=>!!t));this._actionSelector(r),this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null)}}}_range(t,e){var o,i=[];if(t<=e)for(o=t;o<=e;o++)i.push(o);else for(o=t;e<=o;o--)i.push(o);return i}_shiftScroll(t){var e,o,i,l,n=this,s=this.s.scroll,a=!1,d=t.type.includes("touch")?t.touches[0].clientX:t.pageX-c.scrollX,t=t.type.includes("touch")?t.touches[0].clientY:t.pageY-c.scrollY;t<65?e=-5:t>s.windowHeight-65&&(e=5),d<65?o=-5:d>s.windowWidth-65&&(o=5),null!==s.dtTop&&t<s.dtTop+65?i=-5:null!==s.dtTop&&t>s.dtTop+s.dtHeight-65&&(i=5),null!==s.dtLeft&&d<s.dtLeft+65?l=-5:null!==s.dtLeft&&d>s.dtLeft+s.dtWidth-65&&(l=5),e||o||i||l?(s.windowVert=e,s.windowHoriz=o,s.dtVert=i,s.dtHoriz=l,a=!0):this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null),!this.s.scrollInterval&&a&&(this.s.scrollInterval=setInterval(function(){var t;c.scrollTo(c.scrollX+(s.windowHoriz||0),c.scrollY+(s.windowVert||0)),(s.dtVert||s.dtHoriz)&&((t=null==(t=n.dom.dtScroll)?void 0:t.get(0))&&s.dtVert&&(t.scrollTop+=s.dtVert),t)&&s.dtHoriz&&(t.scrollLeft+=s.dtHoriz)},20))}_update(t,i){if(!1!==t){var l,t=this.s.dt,n=t.columns(this.c.columns).indexes(),e=(this._emitEvent("preAutoFill",[t,i]),this._editor(i),null!==this.c.update?this.c.update:!this.c.editor);if(e){for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)l=i[o][t],-1!==n.indexOf(l.index.column)&&l.cell.data(l.set);t.draw(!1)}this._emitEvent("autoFill",[t,i])}}}return r.actions={increment:{available:function(t,e){e=e[0][0].label;return!isNaN(e-parseFloat(e))},option:function(t,e){return t.i18n("autoFill.increment",'Increment / decrement each cell by: <input type="number" value="1">')},execute:function(t,i,e){let l=+i[0][0].data;var n=e?parseFloat(e.find("input").val()):1;for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=l,l+=n}},fill:{available:function(t,e){return!0},option:function(t,e){return t.i18n("autoFill.fill","Fill all cells with <i>%d</i>",e[0][0].label)},execute:function(t,i,e){var l=i[0][0].data;for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=l}},fillHorizontal:{available:function(t,e){return 1<e.length&&1<e[0].length},option:function(t,e){return t.i18n("autoFill.fillHorizontal","Fill cells horizontally")},execute:function(t,i,e){for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=i[o][0].data}},fillVertical:{available:function(t,e){return 1<e.length&&1<e[0].length},option:function(t,e){return t.i18n("autoFill.fillVertical","Fill cells vertically")},execute:function(t,i,e){for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=i[0][t].data}},cancel:{available:function(){return!1},option:function(t){return t.i18n("autoFill.cancel","Cancel")},execute:function(){return!1}}},r.classes={btn:"btn",close:"dtaf-list-close",closeable:"dtaf-list-closeable"},r.defaults={alwaysAsk:!1,closeButton:!0,focus:null,columns:"",enable:!0,update:!0,editor:null,vertical:!0,horizontal:!0},r.version="3.0.1",t.register("autoFill()",function(){return this.inst(this.context)}),t.register("autoFill().enabled()",function(){var t=this.context[0];return!!t.autoFill&&t.autoFill.enabled()}),t.register("autoFill().enable()",function(e){return this.iterator("table",function(t){t.autoFill&&t.autoFill.enable(e)})}),t.register("autoFill().disable()",function(){return this.iterator("table",function(t){t.autoFill&&t.autoFill.disable()})}),h.s(n).on("preInit.dt.autofill",function(t,e){var o,i;"dt"===t.namespace&&(t=e.init.autoFill,o=u.defaults.autoFill,t||o)&&(i={},d.is.plainObject(o)&&d.object.assign(i,o),d.is.plainObject(t)&&d.object.assign(i,t),!1!==t)&&new r(e,i)}),u.AutoFill=r,u});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! AutoFill 3.0.
|
|
1
|
+
/*! AutoFill 3.0.1 for DataTables
|
|
2
2
|
* Copyright (c) SpryMedia Ltd - datatables.net/license
|
|
3
3
|
*/
|
|
4
|
-
import DataTable,{Dom,util,Api}from"datatables.net";if(!DataTable||!DataTable.versionCheck||!DataTable.versionCheck("3"))throw"Warning: AutoFill requires DataTables 3 or greater";var _instance=0;class AutoFill{enabled(){return this.s.enabled}enable(t=!0){let e=this;var o=this.s.namespace;if(!1===t)return this.disable();this.s.enabled=!0,this._focusListener(),this.dom.handle.on("mousedown touchstart",function(t){return e._mousedown(t),!1});function i(){e.s.handle={height:0,width:0},e.dom.handle.css({height:"",width:""}),e.dom.attachedTo&&e._attach(e.dom.attachedTo)}return Dom.w.on("resize"+o,function(){0<Dom.s("div.dtaf-handle").count()&&e.dom.attachedTo&&e._attach(e.dom.attachedTo)}),Dom.w.on("orientationchange"+o,function(){setTimeout(function(){i(),setTimeout(i,150)},50)}),this}disable(){return this.s.enabled=!1,this._focusListenerRemove(),this}constructor(t,e){this.c=util.object.assignDeep({},AutoFill.defaults,e),this.s={dt:new DataTable.Api(t),enabled:!1,end:{column:0,row:0},handle:{height:0,width:0},namespace:".autoFill"+_instance++,scroll:{windowHeight:0,windowWidth:0,dtTop:0,dtLeft:0,dtHeight:0,dtWidth:0},scrollInterval:null,start:{column:0,row:0}},this.dom={attachedTo:null,container:Dom.c("div").classAdd("dtaf-container"),closeButton:Dom.c("button").classAdd(AutoFill.classes.close).html("×"),dtScroll:null,handle:Dom.c("div").classAdd("dtaf-handle"),list:Dom.c("div").classAdd("dtaf-list").html(this.s.dt.i18n("autoFill.info","")).attr("aria-modal",!0).attr("role","dialog").append(Dom.c("div").classAdd("dtaf-list-items")),offsetParent:null,start:null,select:{top:Dom.c("div").classAdd("dtaf-select top"),right:Dom.c("div").classAdd("dtaf-select right"),bottom:Dom.c("div").classAdd("dtaf-select bottom"),left:Dom.c("div").classAdd("dtaf-select left")}},this.dom.list.appendTo(this.dom.container),this._init()}_init(){var t=this.s.dt,e=Dom.s(this.s.dt.table().container()).find("div.dt-scroll-body");t.settings()[0].autoFill=this,e.count()&&"static"===(this.dom.dtScroll=e).css("position")&&e.css("position","relative"),!1!==this.c.enable&&this.enable(),t.on("destroy.autoFill",()=>{this._focusListenerRemove(),this.dom.handle.off()})}_attach(t){var e=this.s.dt,o=e.cell(t).index(),i=this.dom.handle,l=this.s.handle;o&&-1!==e.columns(this.c.columns).indexes().indexOf(o.column)?(this.dom.offsetParent||(this.dom.offsetParent=e.table().node().offsetParent),l.height&&l.width||(i.appendTo("body"),l.height=i.height("outer"),l.width=i.width("outer")),o=this._getPosition(t,this.dom.offsetParent),this.dom.attachedTo=t,i.css({top:o.top+t.offsetHeight-l.height+"px",left:o.left+t.offsetWidth-l.width+"px"}).appendTo(this.dom.offsetParent)):this._detach()}_actionSelector(o){let i=this,l=this.s.dt,n=AutoFill.actions,s=[];if(util.object.each(n,function(t,e){e.available(l,o)&&s.push(t)}),1===s.length&&!1===this.c.alwaysAsk){var t=n[s[0]].execute(l,o,null);this._update(t,o)}else if(1<s.length||this.c.alwaysAsk){var a=this.dom.list.children("div.dtaf-list-items").empty();s.push("cancel");for(let t=0;t<s.length;t++){let e=s[t];a.append(Dom.c("button").classAdd(AutoFill.classes.btn).html(n[e].option(l,o)).append(Dom.c("span").classAdd("dtaf-button").html(l.i18n("autoFill.button",""))).on("click",function(t){"button"===t.target.nodeName.toLowerCase()&&(t=n[e].execute(l,o,Dom.s(this).closest("button")),i._update(t,o),i.dom.container.remove())}))}this.dom.container.appendTo("body"),this.dom.container.on("click",function(t){t.target===i.dom.container.get(0)&&i.dom.container.remove()}),this.c.closeButton&&(this.dom.list.prepend(this.dom.closeButton).classAdd(AutoFill.classes.closeable),this.dom.closeButton.on("click",function(){return i.dom.container.trigger("click")}))}}_detach(){this.dom.attachedTo=null,this.dom.handle.detach()}_drawSelection(t,e){var o,i=this.s.dt,l=this.s.start,n=Dom.s(this.dom.start),t={row:this.c.vertical?i.rows({page:"current"}).nodes().indexOf(t.parentNode):l.row,column:this.c.horizontal?Dom.s(t).index():l.column},s=i.column.index("toData",t.column),a=i.row(":eq("+t.row+")",{page:"current"}),a=Dom.s(i.cell(a.index(),s).node());i.cell(a.get(0)).any()&&-1!==i.columns(this.c.columns).indexes().indexOf(s)&&-1!==t.row&&(this.s.end=t,i=l.row<t.row?n:a,s=l.row<t.row?a:n,o=l.column<t.column?n:a,l=l.column<t.column?a:n,i=this._getPosition(i.get(0)).top,o=this._getPosition(o.get(0)).left,t=this._getPosition(s.get(0)).top+s.height("outer")-i,a=this._getPosition(l.get(0)).left+l.width("outer")-o,(n=this.dom.select).top.css({top:i+"px",left:o+"px",width:a+"px"}),n.left.css({top:i+"px",left:o+"px",height:t+"px"}),n.bottom.css({top:i+t+"px",left:o+"px",width:a+"px"}),n.right.css({top:i+"px",left:o+a+"px",height:t+"px"}))}_editor(l){var n=this.s.dt;let s=this.c.editor;if(s){var a={},d=[],c=s.fields();for(let i=0,t=l.length;i<t;i++)for(let t=0,e=l[i].length;t<e;t++){var r=l[i][t],u=n.settings()[0].columns[r.index.column];let o=u.editField;if(void 0===o){var h=u.data;for(let t=0,e=c.length;t<e;t++){var f=s.field(c[t]);if(f.dataSrc()===h){o=f.name();break}}}if(!o)throw"Could not automatically determine field data. Please see https://datatables.net/tn/11";if("string"!=typeof o)throw"AutoFill with multiple edit fields is not supported";a[o]||(a[o]={});u=n.row(r.index.row).id();a[o][u]=r.set,d.push(r.index)}s.bubble(d,!1).multiSet(a).submit(null,function(){s.close()})}}_emitEvent(t,e){this.s.dt.trigger(t,e)}_focusListener(){var i=this,e=this.s.dt,t=this.s.namespace,o=null!==this.c.focus?this.c.focus:e.init().keys||e.settings()[0].keytable?"focus":"hover";"focus"===o?e.on("key-focus.autoFill",function(t,e,o){i._attach(o.node())}).on("key-blur.autoFill",function(t,e,o){i._detach()}):"click"===o?(Dom.s(e.table().body()).on("click"+t,"td, th",function(t){i._attach(this)}),Dom.s(document.body).on("click"+t,function(t){Dom.s(t.target).closest(e.table().body()).count()||i._detach()})):Dom.s(e.table().body()).on("mouseenter"+t+" touchstart"+t,"td, th",function(t){i._attach(this)}).on("mouseleave"+t+"touchend"+t,function(t){Dom.s(t.relatedTarget).classHas("dtaf-handle")||i._detach()})}_focusListenerRemove(){var t=this.s.namespace,e=this.s.dt;e.off(".autoFill"),Dom.s(e.table().body()).off(t),Dom.s(document.body).off(t),Dom.w.off(t)}_getPosition(t,e){let o=Dom.s(this.s.dt.table().node().offsetParent),i=t,l,n=0,s=0;e&&(o=Dom.s(e));do{var a=i.offsetTop,d=i.offsetLeft;if(l=Dom.s(i.offsetParent),n+=a+ +parseInt(l.css("border-top-width")||"0"),s+=d+ +parseInt(l.css("border-left-width")||"0"),"body"===i.nodeName.toLowerCase())break}while(i=l.get(0),l.get(0)!==o.get(0));return{top:n,left:s}}_mousedown(t){let e=this;var o=this.s.dt,i=(this.dom.start=this.dom.attachedTo,this.s.start={row:o.rows({page:"current"}).nodes().indexOf(Dom.s(this.dom.start).parent().get(0)),column:Dom.s(this.dom.start).index()},Dom.s(document.body).on("mousemove.autoFill touchmove.autoFill",function(t){e._mousemove(t),"touchmove"===t.type&&Dom.s(document.body).one("touchend.autoFill",function(){e._detach()})}).on("mouseup.autoFill touchend.autoFill",function(t){e._mouseup(t)}),this.dom.select),o=o.table().node().offsetParent,i=(i.top.appendTo(o),i.left.appendTo(o),i.right.appendTo(o),i.bottom.appendTo(o),this._drawSelection(this.dom.start,t),this.dom.handle.css("display","none"),this.dom.dtScroll);this.s.scroll={windowHeight:window.innerHeight,windowWidth:window.innerWidth,dtTop:i?i.offset().top:0,dtLeft:i?i.offset().left:0,dtHeight:i?i.height("outer"):0,dtWidth:i?i.width("outer"):0}}_mousemove(t){var e=t.touches&&t.touches.length?document.elementFromPoint(t.touches[0].clientX,t.touches[0].clientY):t.target,o=e.nodeName.toLowerCase();"td"!==o&&"th"!==o||(this._drawSelection(e,t),this._shiftScroll(t))}_mouseup(e){Dom.s(document.body).off(".autoFill");let o=this,d=this.s.dt;var t=this.dom.select,t=(t.top.remove(),t.left.remove(),t.right.remove(),t.bottom.remove(),this.dom.handle.css("display","block"),this.s.start),i=this.s.end;if(t.row!==i.row||t.column!==i.column){var l=d.cell(":eq("+t.row+")",t.column+":visible",{page:"current"});if(Dom.s(l.node()).find("div.DTE").count()){let t=d.editor();t.on("submitSuccess.dtaf close.dtaf",function(){t.off(".dtaf"),setTimeout(function(){o._mouseup(e)},100)}).on("submitComplete.dtaf preSubmitCancelled.dtaf close.dtaf",function(){t.off(".dtaf")}),void t.submit()}else{let n=this._range(t.row,i.row);var c=this._range(t.column,i.column),r=[];let s=d.settings()[0].columns,a=d.columns(this.c.columns).indexes();for(let l=0;l<n.length;l++)r.push(c.map(function(t){var e=d.row(":eq("+n[l]+")",{page:"current"}),e=d.cell(e.index(),t+":visible");let o=e.data();var t=e.index(),i=s[t.column].editField;if(void 0!==i&&(o=DataTable.util.get(i)(d.row(t.row).data())),-1!==a.indexOf(t.column))return{cell:e,data:o,label:e.data(),index:t}}).filter(t=>!!t));this._actionSelector(r),this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null)}}}_range(t,e){var o,i=[];if(t<=e)for(o=t;o<=e;o++)i.push(o);else for(o=t;e<=o;o--)i.push(o);return i}_shiftScroll(t){var e,o,i,l,n=this,s=this.s.scroll,a=!1,d=t.type.includes("touch")?t.touches[0].clientX:t.pageX-window.scrollX,t=t.type.includes("touch")?t.touches[0].clientY:t.pageY-window.scrollY;t<65?e=-5:t>s.windowHeight-65&&(e=5),d<65?o=-5:d>s.windowWidth-65&&(o=5),null!==s.dtTop&&t<s.dtTop+65?i=-5:null!==s.dtTop&&t>s.dtTop+s.dtHeight-65&&(i=5),null!==s.dtLeft&&d<s.dtLeft+65?l=-5:null!==s.dtLeft&&d>s.dtLeft+s.dtWidth-65&&(l=5),e||o||i||l?(s.windowVert=e,s.windowHoriz=o,s.dtVert=i,s.dtHoriz=l,a=!0):this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null),!this.s.scrollInterval&&a&&(this.s.scrollInterval=setInterval(function(){var t;window.scrollTo(window.scrollX+(s.windowHoriz||0),window.scrollY+(s.windowVert||0)),(s.dtVert||s.dtHoriz)&&((t=null==(t=n.dom.dtScroll)?void 0:t.get(0))&&s.dtVert&&(t.scrollTop+=s.dtVert),t)&&s.dtHoriz&&(t.scrollLeft+=s.dtHoriz)},20))}_update(t,i){if(!1!==t){var l,t=this.s.dt,n=t.columns(this.c.columns).indexes(),e=(this._emitEvent("preAutoFill",[t,i]),this._editor(i),null!==this.c.update?this.c.update:!this.c.editor);if(e){for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)l=i[o][t],-1!==n.indexOf(l.index.column)&&l.cell.data(l.set);t.draw(!1)}this._emitEvent("autoFill",[t,i])}}}AutoFill.actions={increment:{available:function(t,e){e=e[0][0].label;return!isNaN(e-parseFloat(e))},option:function(t,e){return t.i18n("autoFill.increment",'Increment / decrement each cell by: <input type="number" value="1">')},execute:function(t,i,e){let l=+i[0][0].data;var n=e?parseFloat(e.find("input").val()):1;for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=l,l+=n}},fill:{available:function(t,e){return!0},option:function(t,e){return t.i18n("autoFill.fill","Fill all cells with <i>%d</i>",e[0][0].label)},execute:function(t,i,e){var l=i[0][0].data;for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=l}},fillHorizontal:{available:function(t,e){return 1<e.length&&1<e[0].length},option:function(t,e){return t.i18n("autoFill.fillHorizontal","Fill cells horizontally")},execute:function(t,i,e){for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=i[o][0].data}},fillVertical:{available:function(t,e){return 1<e.length&&1<e[0].length},option:function(t,e){return t.i18n("autoFill.fillVertical","Fill cells vertically")},execute:function(t,i,e){for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=i[0][t].data}},cancel:{available:function(){return!1},option:function(t){return t.i18n("autoFill.cancel","Cancel")},execute:function(){return!1}}},AutoFill.classes={btn:"btn",close:"dtaf-list-close",closeable:"dtaf-list-closeable"},AutoFill.defaults={alwaysAsk:!1,closeButton:!0,focus:null,columns:"",enable:!0,update:!0,editor:null,vertical:!0,horizontal:!0},AutoFill.version="3.0.0",Api.register("autoFill()",function(){return this.inst(this.context)}),Api.register("autoFill().enabled()",function(){var t=this.context[0];return!!t.autoFill&&t.autoFill.enabled()}),Api.register("autoFill().enable()",function(e){return this.iterator("table",function(t){t.autoFill&&t.autoFill.enable(e)})}),Api.register("autoFill().disable()",function(){return this.iterator("table",function(t){t.autoFill&&t.autoFill.disable()})}),Dom.s(document).on("preInit.dt.autofill",function(t,e){var o,i;"dt"===t.namespace&&(t=e.init.autoFill,o=DataTable.defaults.autoFill,t||o)&&(i={},util.is.plainObject(o)&&util.object.assign(i,o),util.is.plainObject(t)&&util.object.assign(i,t),!1!==t)&&new AutoFill(e,i)}),DataTable.AutoFill=AutoFill;export default DataTable;
|
|
4
|
+
import DataTable,{Dom,util,Api}from"datatables.net";if(!DataTable||!DataTable.versionCheck||!DataTable.versionCheck("3"))throw"Warning: AutoFill requires DataTables 3 or greater";var _instance=0;class AutoFill{enabled(){return this.s.enabled}enable(t=!0){let e=this;var o=this.s.namespace;if(!1===t)return this.disable();this.s.enabled=!0,this._focusListener(),this.dom.handle.on("mousedown touchstart",function(t){return e._mousedown(t),!1});function i(){e.s.handle={height:0,width:0},e.dom.handle.css({height:"",width:""}),e.dom.attachedTo&&e._attach(e.dom.attachedTo)}return Dom.w.on("resize"+o,function(){0<Dom.s("div.dtaf-handle").count()&&e.dom.attachedTo&&e._attach(e.dom.attachedTo)}),Dom.w.on("orientationchange"+o,function(){setTimeout(function(){i(),setTimeout(i,150)},50)}),this}disable(){return this.s.enabled=!1,this._focusListenerRemove(),this}constructor(t,e){this.c=util.object.assignDeep({},AutoFill.defaults,e),this.s={dt:new DataTable.Api(t),enabled:!1,end:{column:0,row:0},handle:{height:0,width:0},namespace:".autoFill"+_instance++,scroll:{windowHeight:0,windowWidth:0,dtTop:0,dtLeft:0,dtHeight:0,dtWidth:0},scrollInterval:null,start:{column:0,row:0}},this.dom={attachedTo:null,container:Dom.c("div").classAdd("dtaf-container"),closeButton:Dom.c("button").classAdd(AutoFill.classes.close).html("×"),dtScroll:null,handle:Dom.c("div").classAdd("dtaf-handle"),list:Dom.c("div").classAdd("dtaf-list").html(this.s.dt.i18n("autoFill.info","")).attr("aria-modal",!0).attr("role","dialog").append(Dom.c("div").classAdd("dtaf-list-items")),offsetParent:null,start:null,select:{top:Dom.c("div").classAdd("dtaf-select top"),right:Dom.c("div").classAdd("dtaf-select right"),bottom:Dom.c("div").classAdd("dtaf-select bottom"),left:Dom.c("div").classAdd("dtaf-select left")}},this.dom.list.appendTo(this.dom.container),this._init()}_init(){var t=this.s.dt,e=Dom.s(this.s.dt.table().container()).find("div.dt-scroll-body");t.settings()[0].autoFill=this,e.count()&&"static"===(this.dom.dtScroll=e).css("position")&&e.css("position","relative"),!1!==this.c.enable&&this.enable(),t.on("destroy.autoFill",()=>{this._focusListenerRemove(),this.dom.handle.off()})}_attach(t){var e=this.s.dt,o=e.cell(t).index(),i=this.dom.handle,l=this.s.handle;o&&-1!==e.columns(this.c.columns).indexes().indexOf(o.column)?(this.dom.offsetParent||(this.dom.offsetParent=e.table().node().offsetParent),l.height&&l.width||(i.appendTo("body"),l.height=i.height("outer"),l.width=i.width("outer")),o=this._getPosition(t,this.dom.offsetParent),this.dom.attachedTo=t,i.css({top:o.top+t.offsetHeight-l.height+"px",left:o.left+t.offsetWidth-l.width+"px"}).appendTo(this.dom.offsetParent)):this._detach()}_actionSelector(o){let i=this,l=this.s.dt,n=AutoFill.actions,s=[];if(util.object.each(n,function(t,e){e.available(l,o)&&s.push(t)}),1===s.length&&!1===this.c.alwaysAsk){var t=n[s[0]].execute(l,o,null);this._update(t,o)}else if(1<s.length||this.c.alwaysAsk){var a=this.dom.list.children("div.dtaf-list-items").empty();s.push("cancel");for(let t=0;t<s.length;t++){let e=s[t];a.append(Dom.c("button").classAdd(AutoFill.classes.btn).html(n[e].option(l,o)).append(Dom.c("span").classAdd("dtaf-button").html(l.i18n("autoFill.button",""))).on("click",function(t){"button"===t.target.nodeName.toLowerCase()&&(t=n[e].execute(l,o,Dom.s(this).closest("button")),i._update(t,o),i.dom.container.remove())}))}this.dom.container.appendTo("body"),this.dom.container.on("click",function(t){t.target===i.dom.container.get(0)&&i.dom.container.remove()}),this.c.closeButton&&(this.dom.list.prepend(this.dom.closeButton).classAdd(AutoFill.classes.closeable),this.dom.closeButton.on("click",function(){return i.dom.container.trigger("click")}))}}_detach(){this.dom.attachedTo=null,this.dom.handle.detach()}_drawSelection(t,e){var o,i=this.s.dt,l=this.s.start,n=Dom.s(this.dom.start),t={row:this.c.vertical?i.rows({page:"current"}).nodes().indexOf(t.parentNode):l.row,column:this.c.horizontal?Dom.s(t).index():l.column},s=i.column.index("toData",t.column),a=i.row(":eq("+t.row+")",{page:"current"}),a=Dom.s(i.cell(a.index(),s).node());i.cell(a.get(0)).any()&&-1!==i.columns(this.c.columns).indexes().indexOf(s)&&-1!==t.row&&(this.s.end=t,i=l.row<t.row?n:a,s=l.row<t.row?a:n,o=l.column<t.column?n:a,l=l.column<t.column?a:n,i=this._getPosition(i.get(0)).top,o=this._getPosition(o.get(0)).left,t=this._getPosition(s.get(0)).top+s.height("outer")-i,a=this._getPosition(l.get(0)).left+l.width("outer")-o,(n=this.dom.select).top.css({top:i+"px",left:o+"px",width:a+"px"}),n.left.css({top:i+"px",left:o+"px",height:t+"px"}),n.bottom.css({top:i+t+"px",left:o+"px",width:a+"px"}),n.right.css({top:i+"px",left:o+a+"px",height:t+"px"}))}_editor(l){var n=this.s.dt;let s=this.c.editor;if(s){var a={},d=[],c=s.fields();for(let i=0,t=l.length;i<t;i++)for(let t=0,e=l[i].length;t<e;t++){var r=l[i][t],u=n.settings()[0].columns[r.index.column];let o=u.editField;if(void 0===o){var h=u.data;for(let t=0,e=c.length;t<e;t++){var f=s.field(c[t]);if(f.dataSrc()===h){o=f.name();break}}}if(!o)throw"Could not automatically determine field data. Please see https://datatables.net/tn/11";if("string"!=typeof o)throw"AutoFill with multiple edit fields is not supported";a[o]||(a[o]={});u=n.row(r.index.row).id();a[o][u]=r.set,d.push(r.index)}s.bubble(d,!1).multiSet(a).submit(null,function(){s.close()})}}_emitEvent(t,e){this.s.dt.trigger(t,e)}_focusListener(){var i=this,e=this.s.dt,t=this.s.namespace,o=null!==this.c.focus?this.c.focus:e.init().keys||e.settings()[0].keytable?"focus":"hover";"focus"===o?e.on("key-focus.autoFill",function(t,e,o){i._attach(o.node())}).on("key-blur.autoFill",function(t,e,o){i._detach()}):"click"===o?(Dom.s(e.table().body()).on("click"+t,"td, th",function(t){i._attach(this)}),Dom.s(document.body).on("click"+t,function(t){Dom.s(t.target).closest(e.table().body()).count()||i._detach()})):Dom.s(e.table().body()).on("mouseenter"+t+" touchstart"+t,"td, th",function(t){i._attach(this)}).on("mouseleave"+t+"touchend"+t,function(t){Dom.s(t.relatedTarget).classHas("dtaf-handle")||i._detach()})}_focusListenerRemove(){var t=this.s.namespace,e=this.s.dt;e.off(".autoFill"),Dom.s(e.table().body()).off(t),Dom.s(document.body).off(t),Dom.w.off(t)}_getPosition(t,e){let o=Dom.s(this.s.dt.table().node().offsetParent),i=t,l,n=0,s=0;e&&(o=Dom.s(e));do{var a=i.offsetTop,d=i.offsetLeft;if(l=Dom.s(i.offsetParent),n+=a+ +parseInt(l.css("border-top-width")||"0"),s+=d+ +parseInt(l.css("border-left-width")||"0"),"body"===i.nodeName.toLowerCase())break}while(i=l.get(0),l.get(0)!==o.get(0));return{top:n,left:s}}_mousedown(t){let e=this;var o=this.s.dt,i=(this.dom.start=this.dom.attachedTo,this.s.start={row:o.rows({page:"current"}).nodes().indexOf(Dom.s(this.dom.start).parent().get(0)),column:Dom.s(this.dom.start).index()},Dom.s(document.body).on("mousemove.autoFill touchmove.autoFill",function(t){e._mousemove(t),"touchmove"===t.type&&Dom.s(document.body).one("touchend.autoFill",function(){e._detach()})}).on("mouseup.autoFill touchend.autoFill",function(t){e._mouseup(t)}),this.dom.select),o=o.table().node().offsetParent,i=(i.top.appendTo(o),i.left.appendTo(o),i.right.appendTo(o),i.bottom.appendTo(o),this._drawSelection(this.dom.start,t),this.dom.handle.css("display","none"),this.dom.dtScroll);this.s.scroll={windowHeight:window.innerHeight,windowWidth:window.innerWidth,dtTop:i?i.offset().top:0,dtLeft:i?i.offset().left:0,dtHeight:i?i.height("outer"):0,dtWidth:i?i.width("outer"):0}}_mousemove(t){var e=t.touches&&t.touches.length?document.elementFromPoint(t.touches[0].clientX,t.touches[0].clientY):t.target,o=e.nodeName.toLowerCase();"td"!==o&&"th"!==o||(this._drawSelection(e,t),this._shiftScroll(t))}_mouseup(e){Dom.s(document.body).off(".autoFill");let o=this,d=this.s.dt;var t=this.dom.select,t=(t.top.remove(),t.left.remove(),t.right.remove(),t.bottom.remove(),this.dom.handle.css("display","block"),this.s.start),i=this.s.end;if(t.row!==i.row||t.column!==i.column){var l=d.cell(":eq("+t.row+")",t.column+":visible",{page:"current"});if(Dom.s(l.node()).find("div.DTE").count()){let t=d.editor();t.on("submitSuccess.dtaf close.dtaf",function(){t.off(".dtaf"),setTimeout(function(){o._mouseup(e)},100)}).on("submitComplete.dtaf preSubmitCancelled.dtaf close.dtaf",function(){t.off(".dtaf")}),void t.submit()}else{let n=this._range(t.row,i.row);var c=this._range(t.column,i.column),r=[];let s=d.settings()[0].columns,a=d.columns(this.c.columns).indexes();for(let l=0;l<n.length;l++)r.push(c.map(function(t){var e=d.row(":eq("+n[l]+")",{page:"current"}),e=d.cell(e.index(),t+":visible");let o=e.data();var t=e.index(),i=s[t.column].editField;if(void 0!==i&&(o=DataTable.util.get(i)(d.row(t.row).data())),-1!==a.indexOf(t.column))return{cell:e,data:o,label:e.data(),index:t}}).filter(t=>!!t));this._actionSelector(r),this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null)}}}_range(t,e){var o,i=[];if(t<=e)for(o=t;o<=e;o++)i.push(o);else for(o=t;e<=o;o--)i.push(o);return i}_shiftScroll(t){var e,o,i,l,n=this,s=this.s.scroll,a=!1,d=t.type.includes("touch")?t.touches[0].clientX:t.pageX-window.scrollX,t=t.type.includes("touch")?t.touches[0].clientY:t.pageY-window.scrollY;t<65?e=-5:t>s.windowHeight-65&&(e=5),d<65?o=-5:d>s.windowWidth-65&&(o=5),null!==s.dtTop&&t<s.dtTop+65?i=-5:null!==s.dtTop&&t>s.dtTop+s.dtHeight-65&&(i=5),null!==s.dtLeft&&d<s.dtLeft+65?l=-5:null!==s.dtLeft&&d>s.dtLeft+s.dtWidth-65&&(l=5),e||o||i||l?(s.windowVert=e,s.windowHoriz=o,s.dtVert=i,s.dtHoriz=l,a=!0):this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null),!this.s.scrollInterval&&a&&(this.s.scrollInterval=setInterval(function(){var t;window.scrollTo(window.scrollX+(s.windowHoriz||0),window.scrollY+(s.windowVert||0)),(s.dtVert||s.dtHoriz)&&((t=null==(t=n.dom.dtScroll)?void 0:t.get(0))&&s.dtVert&&(t.scrollTop+=s.dtVert),t)&&s.dtHoriz&&(t.scrollLeft+=s.dtHoriz)},20))}_update(t,i){if(!1!==t){var l,t=this.s.dt,n=t.columns(this.c.columns).indexes(),e=(this._emitEvent("preAutoFill",[t,i]),this._editor(i),null!==this.c.update?this.c.update:!this.c.editor);if(e){for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)l=i[o][t],-1!==n.indexOf(l.index.column)&&l.cell.data(l.set);t.draw(!1)}this._emitEvent("autoFill",[t,i])}}}AutoFill.actions={increment:{available:function(t,e){e=e[0][0].label;return!isNaN(e-parseFloat(e))},option:function(t,e){return t.i18n("autoFill.increment",'Increment / decrement each cell by: <input type="number" value="1">')},execute:function(t,i,e){let l=+i[0][0].data;var n=e?parseFloat(e.find("input").val()):1;for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=l,l+=n}},fill:{available:function(t,e){return!0},option:function(t,e){return t.i18n("autoFill.fill","Fill all cells with <i>%d</i>",e[0][0].label)},execute:function(t,i,e){var l=i[0][0].data;for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=l}},fillHorizontal:{available:function(t,e){return 1<e.length&&1<e[0].length},option:function(t,e){return t.i18n("autoFill.fillHorizontal","Fill cells horizontally")},execute:function(t,i,e){for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=i[o][0].data}},fillVertical:{available:function(t,e){return 1<e.length&&1<e[0].length},option:function(t,e){return t.i18n("autoFill.fillVertical","Fill cells vertically")},execute:function(t,i,e){for(let o=0,t=i.length;o<t;o++)for(let t=0,e=i[o].length;t<e;t++)i[o][t].set=i[0][t].data}},cancel:{available:function(){return!1},option:function(t){return t.i18n("autoFill.cancel","Cancel")},execute:function(){return!1}}},AutoFill.classes={btn:"btn",close:"dtaf-list-close",closeable:"dtaf-list-closeable"},AutoFill.defaults={alwaysAsk:!1,closeButton:!0,focus:null,columns:"",enable:!0,update:!0,editor:null,vertical:!0,horizontal:!0},AutoFill.version="3.0.1",Api.register("autoFill()",function(){return this.inst(this.context)}),Api.register("autoFill().enabled()",function(){var t=this.context[0];return!!t.autoFill&&t.autoFill.enabled()}),Api.register("autoFill().enable()",function(e){return this.iterator("table",function(t){t.autoFill&&t.autoFill.enable(e)})}),Api.register("autoFill().disable()",function(){return this.iterator("table",function(t){t.autoFill&&t.autoFill.disable()})}),Dom.s(document).on("preInit.dt.autofill",function(t,e){var o,i;"dt"===t.namespace&&(t=e.init.autoFill,o=DataTable.defaults.autoFill,t||o)&&(i={},util.is.plainObject(o)&&util.object.assign(i,o),util.is.plainObject(t)&&util.object.assign(i,t),!1!==t)&&new AutoFill(e,i)}),DataTable.AutoFill=AutoFill;export default DataTable;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! AutoFill 3.0.
|
|
1
|
+
/*! AutoFill 3.0.1 for DataTables
|
|
2
2
|
* Copyright (c) SpryMedia Ltd - datatables.net/license
|
|
3
3
|
*/
|
|
4
4
|
|
|
@@ -898,7 +898,7 @@ AutoFill.defaults = {
|
|
|
898
898
|
horizontal: true
|
|
899
899
|
};
|
|
900
900
|
/** AutoFill version */
|
|
901
|
-
AutoFill.version = '3.0.
|
|
901
|
+
AutoFill.version = '3.0.1';
|
|
902
902
|
|
|
903
903
|
// Doesn't do anything - Not documented
|
|
904
904
|
Api.register('autoFill()', function () {
|
package/package.json
CHANGED
package/types/types.d.ts
CHANGED
|
@@ -1,13 +1,100 @@
|
|
|
1
|
-
import
|
|
2
|
-
export * from 'datatables.net';
|
|
1
|
+
import DataTables, { ColumnSelector, Api, ApiCellMethods, CellIdxWithVisible, Dom } from 'datatables.net';
|
|
3
2
|
export { default } from 'datatables.net';
|
|
4
3
|
|
|
4
|
+
declare module 'datatables.net' {
|
|
5
|
+
interface Options {
|
|
6
|
+
/**
|
|
7
|
+
* autoFill extension options
|
|
8
|
+
*/
|
|
9
|
+
autoFill?: boolean | Partial<AutoFillDefaults>;
|
|
10
|
+
}
|
|
11
|
+
interface Defaults {
|
|
12
|
+
/**
|
|
13
|
+
* autoFill extension options
|
|
14
|
+
*/
|
|
15
|
+
autoFill?: AutoFillDefaults;
|
|
16
|
+
}
|
|
17
|
+
interface Language {
|
|
18
|
+
/**
|
|
19
|
+
* AutoFill language options
|
|
20
|
+
*/
|
|
21
|
+
autoFill?: ConfigAutoFillLanguage;
|
|
22
|
+
}
|
|
23
|
+
interface Api<T> {
|
|
24
|
+
/**
|
|
25
|
+
* AutoFill methods container
|
|
26
|
+
*
|
|
27
|
+
* @returns Api for chaining with the additional autoFill methods
|
|
28
|
+
*/
|
|
29
|
+
autoFill: ApiAutoFill<T>;
|
|
30
|
+
}
|
|
31
|
+
interface DataTablesStatic {
|
|
32
|
+
/**
|
|
33
|
+
* AutoFill class
|
|
34
|
+
*/
|
|
35
|
+
AutoFill: AutoFill;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
interface ConfigAutoFillLanguage {
|
|
39
|
+
/**
|
|
40
|
+
* Multi-fill selector button text
|
|
41
|
+
*/
|
|
42
|
+
button?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Multi-fill selector cancel option message
|
|
45
|
+
*/
|
|
46
|
+
cancel?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Multi-fill selector message for the _full fill_ fill type
|
|
49
|
+
*/
|
|
50
|
+
fill?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Multi-fill selector message for the _horizontal fill_ fill type
|
|
53
|
+
*/
|
|
54
|
+
fillHorizontal?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Multi-fill selector message for the _vertical fill_ fill type
|
|
57
|
+
*/
|
|
58
|
+
fillVertical?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Multi-fill selector message for the _increment_ fill type
|
|
61
|
+
*/
|
|
62
|
+
increment?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Information message shown at the top of the fill type selector
|
|
65
|
+
*/
|
|
66
|
+
info?: string;
|
|
67
|
+
}
|
|
68
|
+
interface ApiAutoFill<T> {
|
|
69
|
+
(): ApiAutoFillMethods<T>;
|
|
70
|
+
}
|
|
71
|
+
interface ApiAutoFillMethods<T> extends Api<T> {
|
|
72
|
+
/**
|
|
73
|
+
* Disable AutoFill. Please note that this disallows future interactions with the table (until re-enabled).
|
|
74
|
+
*
|
|
75
|
+
* @returns DataTables Api instance
|
|
76
|
+
*/
|
|
77
|
+
disable(): Api<T>;
|
|
78
|
+
/**
|
|
79
|
+
* Enable end user and API modification of the focused cells in the DataTable. Differing levels of enablement are available via the optional parameter.
|
|
80
|
+
*
|
|
81
|
+
* @param flag can be true or false to signify whether to enable or disable
|
|
82
|
+
* @returns DataTables Api instance
|
|
83
|
+
*/
|
|
84
|
+
enable(flag?: string | boolean): Api<T>;
|
|
85
|
+
/**
|
|
86
|
+
* This method will return a boolean value indicating if AutoFill is enabled or not on the selected table.
|
|
87
|
+
*
|
|
88
|
+
* @returns boolean signifying if autofill is enables
|
|
89
|
+
*/
|
|
90
|
+
enabled(): boolean;
|
|
91
|
+
}
|
|
5
92
|
interface Classes {
|
|
6
93
|
btn: string;
|
|
7
94
|
close: string;
|
|
8
95
|
closeable: string;
|
|
9
96
|
}
|
|
10
|
-
interface
|
|
97
|
+
interface AutoFillDefaults {
|
|
11
98
|
/** Ask user what they want to do, even for a single option */
|
|
12
99
|
alwaysAsk: boolean;
|
|
13
100
|
/** Show a "Close" button in the list of options */
|
|
@@ -27,6 +114,34 @@ interface Defaults {
|
|
|
27
114
|
/** Enable horizontal fill */
|
|
28
115
|
horizontal: boolean;
|
|
29
116
|
}
|
|
117
|
+
/** Common and useful DOM elements for the class instance */
|
|
118
|
+
interface InternalDom {
|
|
119
|
+
attachedTo: HTMLElement | null;
|
|
120
|
+
/** Fill type chooser background */
|
|
121
|
+
container: Dom;
|
|
122
|
+
/** Popover close button */
|
|
123
|
+
closeButton: Dom;
|
|
124
|
+
/** DataTables scrolling container */
|
|
125
|
+
dtScroll: Dom | null;
|
|
126
|
+
/** AutoFill handle */
|
|
127
|
+
handle: Dom;
|
|
128
|
+
/** Fill type chooser */
|
|
129
|
+
list: Dom;
|
|
130
|
+
/** Offset parent element */
|
|
131
|
+
offsetParent: HTMLElement | null;
|
|
132
|
+
/**
|
|
133
|
+
* Selected cells outline - Need to use 4 elements, otherwise the mouse over
|
|
134
|
+
* if you back into the selected rectangle will be over that element, rather
|
|
135
|
+
* than the cells!
|
|
136
|
+
*/
|
|
137
|
+
select: {
|
|
138
|
+
top: Dom;
|
|
139
|
+
right: Dom;
|
|
140
|
+
bottom: Dom;
|
|
141
|
+
left: Dom;
|
|
142
|
+
};
|
|
143
|
+
start: HTMLElement | null;
|
|
144
|
+
}
|
|
30
145
|
interface Action {
|
|
31
146
|
available(dt: Api, cells: SelectedCells[][]): boolean;
|
|
32
147
|
option(dt: Api, cells: SelectedCells[][]): string;
|
|
@@ -39,256 +154,41 @@ interface SelectedCells {
|
|
|
39
154
|
label: string;
|
|
40
155
|
set?: any;
|
|
41
156
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*/
|
|
78
|
-
private _attach;
|
|
79
|
-
/**
|
|
80
|
-
* Determine can the fill type should be. This can be automatic, or ask the
|
|
81
|
-
* end user.
|
|
82
|
-
*
|
|
83
|
-
* @param cells Information about the selected cells from the key up
|
|
84
|
-
* function
|
|
85
|
-
*/
|
|
86
|
-
private _actionSelector;
|
|
87
|
-
/**
|
|
88
|
-
* Remove the AutoFill handle from the document
|
|
89
|
-
*/
|
|
90
|
-
private _detach;
|
|
91
|
-
/**
|
|
92
|
-
* Draw the selection outline by calculating the range between the start
|
|
93
|
-
* and end cells, then placing the highlighting elements to draw a rectangle
|
|
94
|
-
*
|
|
95
|
-
* @param target End cell
|
|
96
|
-
* @param e Originating event
|
|
97
|
-
* @private
|
|
98
|
-
*/
|
|
99
|
-
private _drawSelection;
|
|
100
|
-
/**
|
|
101
|
-
* Use the Editor API to perform an update based on the new data for the
|
|
102
|
-
* cells
|
|
103
|
-
*
|
|
104
|
-
* @param cells Information about the selected cells from the key up
|
|
105
|
-
* function
|
|
106
|
-
*/
|
|
107
|
-
private _editor;
|
|
108
|
-
/**
|
|
109
|
-
* Emit an event on the DataTable for listeners
|
|
110
|
-
*
|
|
111
|
-
* @param name Event name
|
|
112
|
-
* @param args Event arguments
|
|
113
|
-
*/
|
|
114
|
-
private _emitEvent;
|
|
115
|
-
/**
|
|
116
|
-
* Attach suitable listeners (based on the configuration) that will attach
|
|
117
|
-
* and detach the AutoFill handle in the document.
|
|
118
|
-
*/
|
|
119
|
-
private _focusListener;
|
|
120
|
-
/**
|
|
121
|
-
* Clean up the event listeners
|
|
122
|
-
*/
|
|
123
|
-
private _focusListenerRemove;
|
|
124
|
-
/**
|
|
125
|
-
* Get the position of a node, relative to another, including any scrolling
|
|
126
|
-
* offsets.
|
|
127
|
-
*
|
|
128
|
-
* @param node Node to get the position of
|
|
129
|
-
* @param targetHost Node to use as the parent
|
|
130
|
-
* @return Offset calculation
|
|
131
|
-
*/
|
|
132
|
-
private _getPosition;
|
|
133
|
-
/**
|
|
134
|
-
* Start mouse drag - selects the start cell
|
|
135
|
-
*
|
|
136
|
-
* @param e Mouse down event
|
|
137
|
-
*/
|
|
138
|
-
private _mousedown;
|
|
139
|
-
/**
|
|
140
|
-
* Mouse drag - selects the end cell and update the selection display for
|
|
141
|
-
* the end user
|
|
142
|
-
*
|
|
143
|
-
* @param e Mouse move event
|
|
144
|
-
*/
|
|
145
|
-
private _mousemove;
|
|
146
|
-
/**
|
|
147
|
-
* End mouse drag - perform the update actions
|
|
148
|
-
*
|
|
149
|
-
* @param e Mouse up event
|
|
150
|
-
* @private
|
|
151
|
-
*/
|
|
152
|
-
private _mouseup;
|
|
153
|
-
/**
|
|
154
|
-
* Create an array with a range of numbers defined by the start and end
|
|
155
|
-
* parameters passed in (inclusive!).
|
|
156
|
-
*
|
|
157
|
-
* @param start Start
|
|
158
|
-
* @param end End
|
|
159
|
-
*/
|
|
160
|
-
private _range;
|
|
161
|
-
/**
|
|
162
|
-
* Move the window and DataTables scrolling during a drag to scroll new
|
|
163
|
-
* content into view. This is done by proximity to the edge of the scrolling
|
|
164
|
-
* container of the mouse - for example near the top edge of the window
|
|
165
|
-
* should scroll up. This is a little complicated as there are two elements
|
|
166
|
-
* that can be scrolled - the window and the DataTables scrolling view port
|
|
167
|
-
* (if scrollX and / or scrollY is enabled).
|
|
168
|
-
*
|
|
169
|
-
* @param e Mouse move event object
|
|
170
|
-
*/
|
|
171
|
-
private _shiftScroll;
|
|
172
|
-
/**
|
|
173
|
-
* Update the DataTable after the user has selected what they want to do
|
|
174
|
-
*
|
|
175
|
-
* @param result Return from the `execute` method - can be false internally
|
|
176
|
-
* to do nothing. This is not documented for plug-ins and is used only by
|
|
177
|
-
* the cancel option.
|
|
178
|
-
* @param cells Information about the selected cells from the key up
|
|
179
|
-
* function, augmented with the set values
|
|
180
|
-
*/
|
|
181
|
-
private _update;
|
|
157
|
+
interface Settings {
|
|
158
|
+
/** Host DataTable instance */
|
|
159
|
+
dt: Api;
|
|
160
|
+
/** Enabled setting */
|
|
161
|
+
enabled: boolean;
|
|
162
|
+
end: {
|
|
163
|
+
column: number;
|
|
164
|
+
row: number;
|
|
165
|
+
};
|
|
166
|
+
/** Cached handle size */
|
|
167
|
+
handle: {
|
|
168
|
+
height: number;
|
|
169
|
+
width: number;
|
|
170
|
+
};
|
|
171
|
+
/** Unique namespace for events attached to the document */
|
|
172
|
+
namespace: string;
|
|
173
|
+
start: {
|
|
174
|
+
column: number;
|
|
175
|
+
row: number;
|
|
176
|
+
};
|
|
177
|
+
/** Cached dimension information for use in the mouse move event handler */
|
|
178
|
+
scroll: {
|
|
179
|
+
windowHeight: number;
|
|
180
|
+
windowWidth: number;
|
|
181
|
+
dtTop: number;
|
|
182
|
+
dtLeft: number;
|
|
183
|
+
dtHeight: number;
|
|
184
|
+
dtWidth: number;
|
|
185
|
+
windowVert?: number;
|
|
186
|
+
windowHoriz?: number;
|
|
187
|
+
dtVert?: number;
|
|
188
|
+
dtHoriz?: number;
|
|
189
|
+
};
|
|
190
|
+
/** Interval object used for smooth scrolling */
|
|
191
|
+
scrollInterval: any;
|
|
182
192
|
}
|
|
183
193
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
189
|
-
* DataTables' types integration
|
|
190
|
-
*/
|
|
191
|
-
declare module 'datatables.net' {
|
|
192
|
-
interface Config {
|
|
193
|
-
/**
|
|
194
|
-
* autoFill extension options
|
|
195
|
-
*/
|
|
196
|
-
autoFill?: boolean | Partial<Defaults>;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
interface ConfigLanguage {
|
|
200
|
-
/**
|
|
201
|
-
* AutoFill language options
|
|
202
|
-
*/
|
|
203
|
-
autoFill?: ConfigAutoFillLanguage;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
interface Api<T> {
|
|
207
|
-
/**
|
|
208
|
-
* AutoFill methods container
|
|
209
|
-
*
|
|
210
|
-
* @returns Api for chaining with the additional autoFill methods
|
|
211
|
-
*/
|
|
212
|
-
autoFill: ApiAutoFill<T>;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
interface DataTablesStatic {
|
|
216
|
-
/**
|
|
217
|
-
* AutoFill class
|
|
218
|
-
*/
|
|
219
|
-
AutoFill: AutoFill;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
224
|
-
* Options
|
|
225
|
-
*/
|
|
226
|
-
|
|
227
|
-
interface ConfigAutoFillLanguage {
|
|
228
|
-
/**
|
|
229
|
-
* Multi-fill selector button text
|
|
230
|
-
*/
|
|
231
|
-
button?: string;
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Multi-fill selector cancel option message
|
|
235
|
-
*/
|
|
236
|
-
cancel?: string;
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Multi-fill selector message for the _full fill_ fill type
|
|
240
|
-
*/
|
|
241
|
-
fill?: string;
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Multi-fill selector message for the _horizontal fill_ fill type
|
|
245
|
-
*/
|
|
246
|
-
fillHorizontal?: string;
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Multi-fill selector message for the _vertical fill_ fill type
|
|
250
|
-
*/
|
|
251
|
-
fillVertical?: string;
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Multi-fill selector message for the _increment_ fill type
|
|
255
|
-
*/
|
|
256
|
-
increment?: string;
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Information message shown at the top of the fill type selector
|
|
260
|
-
*/
|
|
261
|
-
info?: string;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
265
|
-
* API
|
|
266
|
-
*/
|
|
267
|
-
|
|
268
|
-
interface ApiAutoFill<T> {
|
|
269
|
-
(): ApiAutoFillMethods<T>;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
interface ApiAutoFillMethods<T> extends Api<T> {
|
|
273
|
-
/**
|
|
274
|
-
* Disable AutoFill. Please note that this disallows future interactions with the table (until re-enabled).
|
|
275
|
-
*
|
|
276
|
-
* @returns DataTables Api instance
|
|
277
|
-
*/
|
|
278
|
-
disable(): Api<T>;
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Enable end user and API modification of the focused cells in the DataTable. Differing levels of enablement are available via the optional parameter.
|
|
282
|
-
*
|
|
283
|
-
* @param flag can be true or false to signify whether to enable or disable
|
|
284
|
-
* @returns DataTables Api instance
|
|
285
|
-
*/
|
|
286
|
-
enable(flag?: string | boolean): Api<T>;
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* This method will return a boolean value indicating if AutoFill is enabled or not on the selected table.
|
|
290
|
-
*
|
|
291
|
-
* @returns boolean signifying if autofill is enables
|
|
292
|
-
*/
|
|
293
|
-
enabled(): boolean;
|
|
294
|
-
}
|
|
194
|
+
export type { Action, AutoFillDefaults, Classes, InternalDom, SelectedCells, Settings };
|