datatables.net-autofill 2.5.3 → 2.7.0
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,5 +1,5 @@
|
|
|
1
|
-
/*! AutoFill 2.
|
|
2
|
-
* ©
|
|
1
|
+
/*! AutoFill 2.7.0
|
|
2
|
+
* © SpryMedia Ltd - datatables.net/license
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
(function( factory ){
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
if (typeof window
|
|
21
|
+
if (typeof window === 'undefined') {
|
|
22
22
|
module.exports = function (root, $) {
|
|
23
23
|
if ( ! root ) {
|
|
24
24
|
// CommonJS environments without a window global must pass a
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
// Browser
|
|
44
44
|
factory( jQuery, window, document );
|
|
45
45
|
}
|
|
46
|
-
}(function( $, window, document
|
|
46
|
+
}(function( $, window, document ) {
|
|
47
47
|
'use strict';
|
|
48
48
|
var DataTable = $.fn.dataTable;
|
|
49
49
|
|
|
@@ -52,7 +52,7 @@ var DataTable = $.fn.dataTable;
|
|
|
52
52
|
/**
|
|
53
53
|
* @summary AutoFill
|
|
54
54
|
* @description Add Excel like click and drag auto-fill options to DataTables
|
|
55
|
-
* @version 2.
|
|
55
|
+
* @version 2.7.0
|
|
56
56
|
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
|
57
57
|
* @copyright SpryMedia Ltd.
|
|
58
58
|
*
|
|
@@ -78,8 +78,8 @@ var _instance = 0;
|
|
|
78
78
|
*/
|
|
79
79
|
var AutoFill = function( dt, opts )
|
|
80
80
|
{
|
|
81
|
-
if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.
|
|
82
|
-
throw( "Warning: AutoFill requires DataTables 1.
|
|
81
|
+
if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.11' ) ) {
|
|
82
|
+
throw( "Warning: AutoFill requires DataTables 1.11 or greater");
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// User and defaults configuration object
|
|
@@ -122,7 +122,7 @@ var AutoFill = function( dt, opts )
|
|
|
122
122
|
* @namespace Common and useful DOM elements for the class instance
|
|
123
123
|
*/
|
|
124
124
|
this.dom = {
|
|
125
|
-
closeButton: $('<div class="dtaf-popover-close"
|
|
125
|
+
closeButton: $('<div class="dtaf-popover-close">×</div>'),
|
|
126
126
|
|
|
127
127
|
/** @type {jQuery} AutoFill handle */
|
|
128
128
|
handle: $('<div class="dt-autofill-handle"/>'),
|
|
@@ -143,7 +143,10 @@ var AutoFill = function( dt, opts )
|
|
|
143
143
|
background: $('<div class="dt-autofill-background"/>'),
|
|
144
144
|
|
|
145
145
|
/** @type {jQuery} Fill type chooser */
|
|
146
|
-
list: $('<div class="dt-autofill-list">'+this.s.dt.i18n('autoFill.info', '')+'
|
|
146
|
+
list: $('<div class="dt-autofill-list">'+this.s.dt.i18n('autoFill.info', '')+'</div>')
|
|
147
|
+
.attr('aria-modal', true)
|
|
148
|
+
.attr('role', 'dialog')
|
|
149
|
+
.append('<div class="dt-autofill-list-items"></div>'),
|
|
147
150
|
|
|
148
151
|
/** @type {jQuery} DataTables scrolling container */
|
|
149
152
|
dtScroll: null,
|
|
@@ -341,24 +344,24 @@ $.extend( AutoFill.prototype, {
|
|
|
341
344
|
var result = actions[ available[0] ].execute( dt, cells );
|
|
342
345
|
this._update( result, cells );
|
|
343
346
|
}
|
|
344
|
-
else if ( available.length > 1 ) {
|
|
347
|
+
else if ( available.length > 1 || this.c.alwaysAsk ) {
|
|
345
348
|
// Multiple actions available - ask the end user what they want to do
|
|
346
|
-
var list = this.dom.list.children('
|
|
349
|
+
var list = this.dom.list.children('div.dt-autofill-list-items').empty();
|
|
347
350
|
|
|
348
351
|
// Add a cancel option
|
|
349
352
|
available.push( 'cancel' );
|
|
350
353
|
|
|
351
354
|
$.each( available, function ( i, name ) {
|
|
352
|
-
list.append( $('<
|
|
353
|
-
.
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
'
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
355
|
+
list.append( $('<button/>')
|
|
356
|
+
.html(actions[ name ].option( dt, cells ))
|
|
357
|
+
.append( $('<span class="dt-autofill-button"/>').html(dt.i18n('autoFill.button', '>')))
|
|
358
|
+
.on( 'click', function (e) {
|
|
359
|
+
if (e.target.nodeName.toLowerCase() !== 'button') {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
|
|
360
363
|
var result = actions[ name ].execute(
|
|
361
|
-
dt, cells, $(this).closest('
|
|
364
|
+
dt, cells, $(this).closest('button')
|
|
362
365
|
);
|
|
363
366
|
that._update( result, cells );
|
|
364
367
|
|
|
@@ -545,7 +548,11 @@ $.extend( AutoFill.prototype, {
|
|
|
545
548
|
editor
|
|
546
549
|
.bubble( nodes, false )
|
|
547
550
|
.multiSet( idValues )
|
|
548
|
-
.submit()
|
|
551
|
+
.submit(null, function () {
|
|
552
|
+
// If an error happens, Editor will show an alert, and then we need
|
|
553
|
+
// to finish the edit since we can't do anything else.
|
|
554
|
+
editor.close();
|
|
555
|
+
});
|
|
549
556
|
},
|
|
550
557
|
|
|
551
558
|
|
|
@@ -834,7 +841,7 @@ $.extend( AutoFill.prototype, {
|
|
|
834
841
|
var editField = dtColumns[ cellIndex.column ].editField;
|
|
835
842
|
|
|
836
843
|
if ( editField !== undefined ) {
|
|
837
|
-
data =
|
|
844
|
+
data = DataTable.util.get( editField )( dt.row( cellIndex.row ).data() );
|
|
838
845
|
}
|
|
839
846
|
|
|
840
847
|
if ( enabledColumns.indexOf(cellIndex.column) === -1 ) {
|
|
@@ -901,7 +908,6 @@ $.extend( AutoFill.prototype, {
|
|
|
901
908
|
_shiftScroll: function ( e )
|
|
902
909
|
{
|
|
903
910
|
var that = this;
|
|
904
|
-
var dt = this.s.dt;
|
|
905
911
|
var scroll = this.s.scroll;
|
|
906
912
|
var runInterval = false;
|
|
907
913
|
var scrollSpeed = 5;
|
|
@@ -1166,7 +1172,7 @@ AutoFill.actions = {
|
|
|
1166
1172
|
* @static
|
|
1167
1173
|
* @type String
|
|
1168
1174
|
*/
|
|
1169
|
-
AutoFill.version = '2.
|
|
1175
|
+
AutoFill.version = '2.7.0';
|
|
1170
1176
|
|
|
1171
1177
|
|
|
1172
1178
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! AutoFill 2.
|
|
2
|
-
* ©
|
|
1
|
+
/*! AutoFill 2.7.0
|
|
2
|
+
* © SpryMedia Ltd - datatables.net/license
|
|
3
3
|
*/
|
|
4
|
-
!function(o){var i,n;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(t){return o(t,window,document)}):"object"==typeof exports?(i=require("jquery"),n=function(t,e){e.fn.dataTable||require("datatables.net")(t,e)},"undefined"!=typeof window?module.exports=function(t,e){return t=t||window,e=e||i(t),n(t,e),o(e,t,t.document)}:(n(window,i),module.exports=o(i,window,window.document))):o(jQuery,window,document)}(function(m,d,p,b){"use strict";function r(t,e){if(!n.versionCheck||!n.versionCheck("1.10.8"))throw"Warning: AutoFill requires DataTables 1.10.8 or greater";this.c=m.extend(!0,{},n.defaults.autoFill,r.defaults,e),this.s={dt:new n.Api(t),namespace:".autoFill"+o++,scroll:{},scrollInterval:null,handle:{height:0,width:0},enabled:!1},this.dom={closeButton:m('<div class="dtaf-popover-close">x</div>'),handle:m('<div class="dt-autofill-handle"/>'),select:{top:m('<div class="dt-autofill-select top"/>'),right:m('<div class="dt-autofill-select right"/>'),bottom:m('<div class="dt-autofill-select bottom"/>'),left:m('<div class="dt-autofill-select left"/>')},background:m('<div class="dt-autofill-background"/>'),list:m('<div class="dt-autofill-list">'+this.s.dt.i18n("autoFill.info","")+"<ul/></div>"),dtScroll:null,offsetParent:null},this._constructor()}var n=m.fn.dataTable,o=0,t=(m.extend(r.prototype,{enabled:function(){return this.s.enabled},enable:function(t){var e=this;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}),m(d).on("resize",function(){0<m("div.dt-autofill-handle").length&&e.dom.attachedTo!==b&&e._attach(e.dom.attachedTo)});function o(){e.s.handle={height:!1,width:!1},m(e.dom.handle).css({height:"",width:""}),e.dom.attachedTo!==b&&e._attach(e.dom.attachedTo)}return m(d).on("orientationchange",function(){setTimeout(function(){o(),setTimeout(o,150)},50)}),this},disable:function(){return this.s.enabled=!1,this._focusListenerRemove(),this},_constructor:function(){var t=this,e=this.s.dt,o=m("div.dataTables_scrollBody",this.s.dt.table().container());e.settings()[0].autoFill=this,o.length&&"static"===(this.dom.dtScroll=o).css("position")&&o.css("position","relative"),!1!==this.c.enable&&this.enable(),e.on("destroy.autoFill",function(){t._focusListenerRemove()})},_attach:function(t){var e=this.s.dt,o=e.cell(t).index(),i=this.dom.handle,n=this.s.handle;o&&-1!==e.columns(this.c.columns).indexes().indexOf(o.column)?(this.dom.offsetParent||(this.dom.offsetParent=m(e.table().node()).offsetParent()),n.height&&n.width||(i.appendTo("body"),n.height=i.outerHeight(),n.width=i.outerWidth()),o=this._getPosition(t,this.dom.offsetParent),this.dom.attachedTo=t,i.css({top:o.top+t.offsetHeight-n.height,left:o.left+t.offsetWidth-n.width}).appendTo(this.dom.offsetParent)):this._detach()},_actionSelector:function(o){var t,i,n=this,l=this.s.dt,s=r.actions,a=[];m.each(s,function(t,e){e.available(l,o)&&a.push(t)}),1===a.length&&!1===this.c.alwaysAsk?(t=s[a[0]].execute(l,o),this._update(t,o)):1<a.length&&(i=this.dom.list.children("ul").empty(),a.push("cancel"),m.each(a,function(t,e){i.append(m("<li/>").append('<div class="dt-autofill-question">'+s[e].option(l,o)+"<div>").append(m('<div class="dt-autofill-button">').append(m('<button class="'+r.classes.btn+'">'+l.i18n("autoFill.button",">")+"</button>"))).on("click",function(){var t=s[e].execute(l,o,m(this).closest("li"));n._update(t,o),n.dom.background.remove(),n.dom.list.remove()}))}),this.dom.background.appendTo("body"),this.dom.background.one("click",function(){n.dom.background.remove(),n.dom.list.remove()}),this.dom.list.appendTo("body"),this.c.closeButton&&(this.dom.list.prepend(this.dom.closeButton).addClass(r.classes.closeable),this.dom.closeButton.on("click",function(){return n.dom.background.click()})),this.dom.list.css("margin-top",this.dom.list.outerHeight()/2*-1))},_detach:function(){this.dom.attachedTo=null,this.dom.handle.detach()},_drawSelection:function(t,e){var o,i=this.s.dt,n=this.s.start,l=m(this.dom.start),t={row:this.c.vertical?i.rows({page:"current"}).nodes().indexOf(t.parentNode):n.row,column:this.c.horizontal?m(t).index():n.column},s=i.column.index("toData",t.column),a=i.row(":eq("+t.row+")",{page:"current"}),a=m(i.cell(a.index(),s).node());i.cell(a).any()&&-1!==i.columns(this.c.columns).indexes().indexOf(s)&&-1!==t.row&&(this.s.end=t,i=n.row<t.row?l:a,s=n.row<t.row?a:l,o=n.column<t.column?l:a,n=n.column<t.column?a:l,i=this._getPosition(i.get(0)).top,o=this._getPosition(o.get(0)).left,t=this._getPosition(s.get(0)).top+s.outerHeight()-i,a=this._getPosition(n.get(0)).left+n.outerWidth()-o,(l=this.dom.select).top.css({top:i,left:o,width:a}),l.left.css({top:i,left:o,height:t}),l.bottom.css({top:i+t,left:o,width:a}),l.right.css({top:i,left:o+a,height:t}))},_editor:function(t){var e=this.s.dt,o=this.c.editor;if(o){for(var i={},n=[],l=o.fields(),s=0,a=t.length;s<a;s++)for(var r=0,d=t[s].length;r<d;r++){var c=t[s][r],u=e.settings()[0].aoColumns[c.index.column],h=u.editField;if(h===b)for(var f=u.mData,m=0,p=l.length;m<p;m++){var v=o.field(l[m]);if(v.dataSrc()===f){h=v.name();break}}if(!h)throw"Could not automatically determine field data. Please see https://datatables.net/tn/11";i[h]||(i[h]={});u=e.row(c.index.row).id();i[h][u]=c.set,n.push(c.index)}o.bubble(n,!1).multiSet(i).submit()}},_emitEvent:function(o,i){this.s.dt.iterator("table",function(t,e){m(t.nTable).triggerHandler(o+".dt",i)})},_focusListener:function(){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?(m(e.table().body()).on("click"+t,"td, th",function(t){i._attach(this)}),m(p.body).on("click"+t,function(t){m(t.target).parents().filter(e.table().body()).length||i._detach()})):m(e.table().body()).on("mouseenter"+t+" touchstart"+t,"td, th",function(t){i._attach(this)}).on("mouseleave"+t+"touchend"+t,function(t){m(t.relatedTarget).hasClass("dt-autofill-handle")||i._detach()})},_focusListenerRemove:function(){var t=this.s.dt;t.off(".autoFill"),m(t.table().body()).off(this.s.namespace),m(p.body).off(this.s.namespace)},_getPosition:function(t,e){var o=t,i=0,n=0;e=e||m(m(this.s.dt.table().node())[0].offsetParent);do{var l=o.offsetTop,s=o.offsetLeft,a=m(o.offsetParent)}while((i+=l+ +parseInt(a.css("border-top-width")||0),n+=s+ +parseInt(a.css("border-left-width")||0),"body"!==o.nodeName.toLowerCase())&&(o=a.get(0),a.get(0)!==e.get(0)));return{top:i,left:n}},_mousedown:function(t){var e=this,o=this.s.dt,i=(this.dom.start=this.dom.attachedTo,this.s.start={row:o.rows({page:"current"}).nodes().indexOf(m(this.dom.start).parent()[0]),column:m(this.dom.start).index()},m(p.body).on("mousemove.autoFill touchmove.autoFill",function(t){e._mousemove(t),"touchmove"===t.type&&m(p.body).one("touchend.autoFill",function(){e._detach()})}).on("mouseup.autoFill touchend.autoFill",function(t){e._mouseup(t)}),this.dom.select),o=m(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:m(d).height(),windowWidth:m(d).width(),dtTop:i?i.offset().top:null,dtLeft:i?i.offset().left:null,dtHeight:i?i.outerHeight():null,dtWidth:i?i.outerWidth():null}},_mousemove:function(t){var e=t.touches&&t.touches.length?p.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:function(t){m(p.body).off(".autoFill");var e=this,n=this.s.dt,o=this.dom.select,o=(o.top.remove(),o.left.remove(),o.right.remove(),o.bottom.remove(),this.dom.handle.css("display","block"),this.s.start),i=this.s.end;if(o.row!==i.row||o.column!==i.column){var l,s=n.cell(":eq("+o.row+")",o.column+":visible",{page:"current"});if(m("div.DTE",s.node()).length)(l=n.editor()).on("submitSuccess.dtaf close.dtaf",function(){l.off(".dtaf"),setTimeout(function(){e._mouseup(t)},100)}).on("submitComplete.dtaf preSubmitCancelled.dtaf close.dtaf",function(){l.off(".dtaf")}),l.submit();else{for(var a=this._range(o.row,i.row),r=this._range(o.column,i.column),d=[],c=n.settings()[0],u=c.aoColumns,h=n.columns(this.c.columns).indexes(),f=0;f<a.length;f++)d.push(m.map(r,function(t){var e=n.row(":eq("+a[f]+")",{page:"current"}),e=n.cell(e.index(),t+":visible"),t=e.data(),o=e.index(),i=u[o.column].editField;if(i!==b&&(t=c.oApi._fnGetObjectDataFn(i)(n.row(o.row).data())),-1!==h.indexOf(o.column))return{cell:e,data:t,label:e.data(),index:o}}));this._actionSelector(d),clearInterval(this.s.scrollInterval),this.s.scrollInterval=null}}},_range:function(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:function(t){var e,o,i,n,l=this,s=(this.s.dt,this.s.scroll),a=!1,r=t.type.includes("touch")?t.touches[0].clientX:t.pageX-d.scrollX,t=t.type.includes("touch")?t.touches[0].clientY:t.pageY-d.scrollY;t<65?e=-5:t>s.windowHeight-65&&(e=5),r<65?o=-5:r>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&&r<s.dtLeft+65?n=-5:null!==s.dtLeft&&r>s.dtLeft+s.dtWidth-65&&(n=5),e||o||i||n?(s.windowVert=e,s.windowHoriz=o,s.dtVert=i,s.dtHoriz=n,a=!0):this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null),!this.s.scrollInterval&&a&&(this.s.scrollInterval=setInterval(function(){var t;d.scrollTo(d.scrollX+(s.windowHoriz||0),d.scrollY+(s.windowVert||0)),(s.dtVert||s.dtHoriz)&&(t=l.dom.dtScroll[0],s.dtVert&&(t.scrollTop+=s.dtVert),s.dtHoriz&&(t.scrollLeft+=s.dtHoriz))},20))},_update:function(t,e){if(!1!==t){var o,t=this.s.dt,i=t.columns(this.c.columns).indexes();if(this._emitEvent("preAutoFill",[t,e]),this._editor(e),null!==this.c.update?this.c.update:!this.c.editor){for(var n=0,l=e.length;n<l;n++)for(var s=0,a=e[n].length;s<a;s++)o=e[n][s],-1!==i.indexOf(o.index.column)&&o.cell.data(o.set);t.draw(!1)}this._emitEvent("autoFill",[t,e])}}}),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,e,o){for(var i=+e[0][0].data,n=+m("input",o).val(),l=0,s=e.length;l<s;l++)for(var a=0,r=e[l].length;a<r;a++)e[l][a].set=i,i+=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,e,o){for(var i=e[0][0].data,n=0,l=e.length;n<l;n++)for(var s=0,a=e[n].length;s<a;s++)e[n][s].set=i}},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,e,o){for(var i=0,n=e.length;i<n;i++)for(var l=0,s=e[i].length;l<s;l++)e[i][l].set=e[i][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,e,o){for(var i=0,n=e.length;i<n;i++)for(var l=0,s=e[i].length;l<s;l++)e[i][l].set=e[0][l].data}},cancel:{available:function(){return!1},option:function(t){return t.i18n("autoFill.cancel","Cancel")},execute:function(){return!1}}},r.version="2.5.3",r.defaults={alwaysAsk:!1,closeButton:!0,focus:null,columns:"",enable:!0,update:null,editor:null,vertical:!0,horizontal:!0},r.classes={btn:"btn",closeable:"dtaf-popover-closeable"},m.fn.dataTable.Api);return t.register("autoFill()",function(){return this}),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()})}),m(p).on("preInit.dt.autofill",function(t,e,o){var i;"dt"===t.namespace&&(t=e.oInit.autoFill,i=n.defaults.autoFill,(t||i)&&(i=m.extend({},t,i),!1!==t&&new r(e,i)))}),n.AutoFill=r,m.fn.DataTable.AutoFill=r,n});
|
|
4
|
+
!function(o){var i,n;"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(t){return o(t,window,document)}):"object"==typeof exports?(i=require("jquery"),n=function(t,e){e.fn.dataTable||require("datatables.net")(t,e)},"undefined"==typeof window?module.exports=function(t,e){return t=t||window,e=e||i(t),n(t,e),o(e,t,t.document)}:(n(window,i),module.exports=o(i,window,window.document))):o(jQuery,window,document)}(function(f,r,m){"use strict";function d(t,e){if(!p.versionCheck||!p.versionCheck("1.11"))throw"Warning: AutoFill requires DataTables 1.11 or greater";this.c=f.extend(!0,{},p.defaults.autoFill,d.defaults,e),this.s={dt:new p.Api(t),namespace:".autoFill"+o++,scroll:{},scrollInterval:null,handle:{height:0,width:0},enabled:!1},this.dom={closeButton:f('<div class="dtaf-popover-close">×</div>'),handle:f('<div class="dt-autofill-handle"/>'),select:{top:f('<div class="dt-autofill-select top"/>'),right:f('<div class="dt-autofill-select right"/>'),bottom:f('<div class="dt-autofill-select bottom"/>'),left:f('<div class="dt-autofill-select left"/>')},background:f('<div class="dt-autofill-background"/>'),list:f('<div class="dt-autofill-list">'+this.s.dt.i18n("autoFill.info","")+"</div>").attr("aria-modal",!0).attr("role","dialog").append('<div class="dt-autofill-list-items"></div>'),dtScroll:null,offsetParent:null},this._constructor()}var p=f.fn.dataTable,o=0,t=(f.extend(d.prototype,{enabled:function(){return this.s.enabled},enable:function(t){var e=this;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}),f(r).on("resize",function(){0<f("div.dt-autofill-handle").length&&void 0!==e.dom.attachedTo&&e._attach(e.dom.attachedTo)});function o(){e.s.handle={height:!1,width:!1},f(e.dom.handle).css({height:"",width:""}),void 0!==e.dom.attachedTo&&e._attach(e.dom.attachedTo)}return f(r).on("orientationchange",function(){setTimeout(function(){o(),setTimeout(o,150)},50)}),this},disable:function(){return this.s.enabled=!1,this._focusListenerRemove(),this},_constructor:function(){var t=this,e=this.s.dt,o=f("div.dataTables_scrollBody",this.s.dt.table().container());e.settings()[0].autoFill=this,o.length&&"static"===(this.dom.dtScroll=o).css("position")&&o.css("position","relative"),!1!==this.c.enable&&this.enable(),e.on("destroy.autoFill",function(){t._focusListenerRemove()})},_attach:function(t){var e=this.s.dt,o=e.cell(t).index(),i=this.dom.handle,n=this.s.handle;o&&-1!==e.columns(this.c.columns).indexes().indexOf(o.column)?(this.dom.offsetParent||(this.dom.offsetParent=f(e.table().node()).offsetParent()),n.height&&n.width||(i.appendTo("body"),n.height=i.outerHeight(),n.width=i.outerWidth()),o=this._getPosition(t,this.dom.offsetParent),this.dom.attachedTo=t,i.css({top:o.top+t.offsetHeight-n.height,left:o.left+t.offsetWidth-n.width}).appendTo(this.dom.offsetParent)):this._detach()},_actionSelector:function(o){var t,i,n=this,l=this.s.dt,s=d.actions,a=[];f.each(s,function(t,e){e.available(l,o)&&a.push(t)}),1===a.length&&!1===this.c.alwaysAsk?(t=s[a[0]].execute(l,o),this._update(t,o)):(1<a.length||this.c.alwaysAsk)&&(i=this.dom.list.children("div.dt-autofill-list-items").empty(),a.push("cancel"),f.each(a,function(t,e){i.append(f("<button/>").html(s[e].option(l,o)).append(f('<span class="dt-autofill-button"/>').html(l.i18n("autoFill.button",">"))).on("click",function(t){"button"===t.target.nodeName.toLowerCase()&&(t=s[e].execute(l,o,f(this).closest("button")),n._update(t,o),n.dom.background.remove(),n.dom.list.remove())}))}),this.dom.background.appendTo("body"),this.dom.background.one("click",function(){n.dom.background.remove(),n.dom.list.remove()}),this.dom.list.appendTo("body"),this.c.closeButton&&(this.dom.list.prepend(this.dom.closeButton).addClass(d.classes.closeable),this.dom.closeButton.on("click",function(){return n.dom.background.click()})),this.dom.list.css("margin-top",this.dom.list.outerHeight()/2*-1))},_detach:function(){this.dom.attachedTo=null,this.dom.handle.detach()},_drawSelection:function(t,e){var o,i=this.s.dt,n=this.s.start,l=f(this.dom.start),t={row:this.c.vertical?i.rows({page:"current"}).nodes().indexOf(t.parentNode):n.row,column:this.c.horizontal?f(t).index():n.column},s=i.column.index("toData",t.column),a=i.row(":eq("+t.row+")",{page:"current"}),a=f(i.cell(a.index(),s).node());i.cell(a).any()&&-1!==i.columns(this.c.columns).indexes().indexOf(s)&&-1!==t.row&&(this.s.end=t,i=n.row<t.row?l:a,s=n.row<t.row?a:l,o=n.column<t.column?l:a,n=n.column<t.column?a:l,i=this._getPosition(i.get(0)).top,o=this._getPosition(o.get(0)).left,t=this._getPosition(s.get(0)).top+s.outerHeight()-i,a=this._getPosition(n.get(0)).left+n.outerWidth()-o,(l=this.dom.select).top.css({top:i,left:o,width:a}),l.left.css({top:i,left:o,height:t}),l.bottom.css({top:i+t,left:o,width:a}),l.right.css({top:i,left:o+a,height:t}))},_editor:function(t){var e=this.s.dt,o=this.c.editor;if(o){for(var i={},n=[],l=o.fields(),s=0,a=t.length;s<a;s++)for(var d=0,r=t[s].length;d<r;d++){var c=t[s][d],u=e.settings()[0].aoColumns[c.index.column],h=u.editField;if(void 0===h)for(var f=u.mData,m=0,p=l.length;m<p;m++){var v=o.field(l[m]);if(v.dataSrc()===f){h=v.name();break}}if(!h)throw"Could not automatically determine field data. Please see https://datatables.net/tn/11";i[h]||(i[h]={});u=e.row(c.index.row).id();i[h][u]=c.set,n.push(c.index)}o.bubble(n,!1).multiSet(i).submit(null,function(){o.close()})}},_emitEvent:function(o,i){this.s.dt.iterator("table",function(t,e){f(t.nTable).triggerHandler(o+".dt",i)})},_focusListener:function(){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?(f(e.table().body()).on("click"+t,"td, th",function(t){i._attach(this)}),f(m.body).on("click"+t,function(t){f(t.target).parents().filter(e.table().body()).length||i._detach()})):f(e.table().body()).on("mouseenter"+t+" touchstart"+t,"td, th",function(t){i._attach(this)}).on("mouseleave"+t+"touchend"+t,function(t){f(t.relatedTarget).hasClass("dt-autofill-handle")||i._detach()})},_focusListenerRemove:function(){var t=this.s.dt;t.off(".autoFill"),f(t.table().body()).off(this.s.namespace),f(m.body).off(this.s.namespace)},_getPosition:function(t,e){var o=t,i=0,n=0;e=e||f(f(this.s.dt.table().node())[0].offsetParent);do{var l=o.offsetTop,s=o.offsetLeft,a=f(o.offsetParent)}while((i+=l+ +parseInt(a.css("border-top-width")||0),n+=s+ +parseInt(a.css("border-left-width")||0),"body"!==o.nodeName.toLowerCase())&&(o=a.get(0),a.get(0)!==e.get(0)));return{top:i,left:n}},_mousedown:function(t){var e=this,o=this.s.dt,i=(this.dom.start=this.dom.attachedTo,this.s.start={row:o.rows({page:"current"}).nodes().indexOf(f(this.dom.start).parent()[0]),column:f(this.dom.start).index()},f(m.body).on("mousemove.autoFill touchmove.autoFill",function(t){e._mousemove(t),"touchmove"===t.type&&f(m.body).one("touchend.autoFill",function(){e._detach()})}).on("mouseup.autoFill touchend.autoFill",function(t){e._mouseup(t)}),this.dom.select),o=f(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:f(r).height(),windowWidth:f(r).width(),dtTop:i?i.offset().top:null,dtLeft:i?i.offset().left:null,dtHeight:i?i.outerHeight():null,dtWidth:i?i.outerWidth():null}},_mousemove:function(t){var e=t.touches&&t.touches.length?m.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:function(t){f(m.body).off(".autoFill");var e=this,n=this.s.dt,o=this.dom.select,o=(o.top.remove(),o.left.remove(),o.right.remove(),o.bottom.remove(),this.dom.handle.css("display","block"),this.s.start),i=this.s.end;if(o.row!==i.row||o.column!==i.column){var l,s=n.cell(":eq("+o.row+")",o.column+":visible",{page:"current"});if(f("div.DTE",s.node()).length)(l=n.editor()).on("submitSuccess.dtaf close.dtaf",function(){l.off(".dtaf"),setTimeout(function(){e._mouseup(t)},100)}).on("submitComplete.dtaf preSubmitCancelled.dtaf close.dtaf",function(){l.off(".dtaf")}),l.submit();else{for(var a=this._range(o.row,i.row),d=this._range(o.column,i.column),r=[],c=n.settings()[0].aoColumns,u=n.columns(this.c.columns).indexes(),h=0;h<a.length;h++)r.push(f.map(d,function(t){var e=n.row(":eq("+a[h]+")",{page:"current"}),e=n.cell(e.index(),t+":visible"),t=e.data(),o=e.index(),i=c[o.column].editField;if(void 0!==i&&(t=p.util.get(i)(n.row(o.row).data())),-1!==u.indexOf(o.column))return{cell:e,data:t,label:e.data(),index:o}}));this._actionSelector(r),clearInterval(this.s.scrollInterval),this.s.scrollInterval=null}}},_range:function(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:function(t){var e,o,i,n,l=this,s=this.s.scroll,a=!1,d=t.type.includes("touch")?t.touches[0].clientX:t.pageX-r.scrollX,t=t.type.includes("touch")?t.touches[0].clientY:t.pageY-r.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?n=-5:null!==s.dtLeft&&d>s.dtLeft+s.dtWidth-65&&(n=5),e||o||i||n?(s.windowVert=e,s.windowHoriz=o,s.dtVert=i,s.dtHoriz=n,a=!0):this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null),!this.s.scrollInterval&&a&&(this.s.scrollInterval=setInterval(function(){var t;r.scrollTo(r.scrollX+(s.windowHoriz||0),r.scrollY+(s.windowVert||0)),(s.dtVert||s.dtHoriz)&&(t=l.dom.dtScroll[0],s.dtVert&&(t.scrollTop+=s.dtVert),s.dtHoriz)&&(t.scrollLeft+=s.dtHoriz)},20))},_update:function(t,e){if(!1!==t){var o,t=this.s.dt,i=t.columns(this.c.columns).indexes();if(this._emitEvent("preAutoFill",[t,e]),this._editor(e),null!==this.c.update?this.c.update:!this.c.editor){for(var n=0,l=e.length;n<l;n++)for(var s=0,a=e[n].length;s<a;s++)o=e[n][s],-1!==i.indexOf(o.index.column)&&o.cell.data(o.set);t.draw(!1)}this._emitEvent("autoFill",[t,e])}}}),d.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,e,o){for(var i=+e[0][0].data,n=+f("input",o).val(),l=0,s=e.length;l<s;l++)for(var a=0,d=e[l].length;a<d;a++)e[l][a].set=i,i+=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,e,o){for(var i=e[0][0].data,n=0,l=e.length;n<l;n++)for(var s=0,a=e[n].length;s<a;s++)e[n][s].set=i}},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,e,o){for(var i=0,n=e.length;i<n;i++)for(var l=0,s=e[i].length;l<s;l++)e[i][l].set=e[i][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,e,o){for(var i=0,n=e.length;i<n;i++)for(var l=0,s=e[i].length;l<s;l++)e[i][l].set=e[0][l].data}},cancel:{available:function(){return!1},option:function(t){return t.i18n("autoFill.cancel","Cancel")},execute:function(){return!1}}},d.version="2.7.0",d.defaults={alwaysAsk:!1,closeButton:!0,focus:null,columns:"",enable:!0,update:null,editor:null,vertical:!0,horizontal:!0},d.classes={btn:"btn",closeable:"dtaf-popover-closeable"},f.fn.dataTable.Api);return t.register("autoFill()",function(){return this}),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()})}),f(m).on("preInit.dt.autofill",function(t,e,o){var i,n;"dt"===t.namespace&&(t=e.oInit.autoFill,i=p.defaults.autoFill,t||i)&&(n=f.extend({},t,i),!1!==t)&&new d(e,n)}),p.AutoFill=d,f.fn.DataTable.AutoFill=d,p});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! AutoFill 2.
|
|
2
|
-
* ©
|
|
1
|
+
/*! AutoFill 2.7.0
|
|
2
|
+
* © SpryMedia Ltd - datatables.net/license
|
|
3
3
|
*/
|
|
4
|
-
import $ from"jquery";import DataTable from"datatables.net";var _instance=0,AutoFill=function(t,e){if(!DataTable.versionCheck||!DataTable.versionCheck("1.10.8"))throw"Warning: AutoFill requires DataTables 1.10.8 or greater";this.c=$.extend(!0,{},DataTable.defaults.autoFill,AutoFill.defaults,e),this.s={dt:new DataTable.Api(t),namespace:".autoFill"+_instance++,scroll:{},scrollInterval:null,handle:{height:0,width:0},enabled:!1},this.dom={closeButton:$('<div class="dtaf-popover-close">x</div>'),handle:$('<div class="dt-autofill-handle"/>'),select:{top:$('<div class="dt-autofill-select top"/>'),right:$('<div class="dt-autofill-select right"/>'),bottom:$('<div class="dt-autofill-select bottom"/>'),left:$('<div class="dt-autofill-select left"/>')},background:$('<div class="dt-autofill-background"/>'),list:$('<div class="dt-autofill-list">'+this.s.dt.i18n("autoFill.info","")+"<ul/></div>"),dtScroll:null,offsetParent:null},this._constructor()},Api=($.extend(AutoFill.prototype,{enabled:function(){return this.s.enabled},enable:function(t){var e=this;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}),$(window).on("resize",function(){0<$("div.dt-autofill-handle").length&&void 0!==e.dom.attachedTo&&e._attach(e.dom.attachedTo)});function o(){e.s.handle={height:!1,width:!1},$(e.dom.handle).css({height:"",width:""}),void 0!==e.dom.attachedTo&&e._attach(e.dom.attachedTo)}return $(window).on("orientationchange",function(){setTimeout(function(){o(),setTimeout(o,150)},50)}),this},disable:function(){return this.s.enabled=!1,this._focusListenerRemove(),this},_constructor:function(){var t=this,e=this.s.dt,o=$("div.dataTables_scrollBody",this.s.dt.table().container());e.settings()[0].autoFill=this,o.length&&"static"===(this.dom.dtScroll=o).css("position")&&o.css("position","relative"),!1!==this.c.enable&&this.enable(),e.on("destroy.autoFill",function(){t._focusListenerRemove()})},_attach:function(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.outerHeight(),l.width=i.outerWidth()),o=this._getPosition(t,this.dom.offsetParent),this.dom.attachedTo=t,i.css({top:o.top+t.offsetHeight-l.height,left:o.left+t.offsetWidth-l.width}).appendTo(this.dom.offsetParent)):this._detach()},_actionSelector:function(o){var t,i,l=this,n=this.s.dt,s=AutoFill.actions,a=[];$.each(s,function(t,e){e.available(n,o)&&a.push(t)}),1===a.length&&!1===this.c.alwaysAsk?(t=s[a[0]].execute(n,o),this._update(t,o)):1<a.length&&(i=this.dom.list.children("ul").empty(),a.push("cancel"),$.each(a,function(t,e){i.append($("<li/>").append('<div class="dt-autofill-question">'+s[e].option(n,o)+"<div>").append($('<div class="dt-autofill-button">').append($('<button class="'+AutoFill.classes.btn+'">'+n.i18n("autoFill.button",">")+"</button>"))).on("click",function(){var t=s[e].execute(n,o,$(this).closest("li"));l._update(t,o),l.dom.background.remove(),l.dom.list.remove()}))}),this.dom.background.appendTo("body"),this.dom.background.one("click",function(){l.dom.background.remove(),l.dom.list.remove()}),this.dom.list.appendTo("body"),this.c.closeButton&&(this.dom.list.prepend(this.dom.closeButton).addClass(AutoFill.classes.closeable),this.dom.closeButton.on("click",function(){return l.dom.background.click()})),this.dom.list.css("margin-top",this.dom.list.outerHeight()/2*-1))},_detach:function(){this.dom.attachedTo=null,this.dom.handle.detach()},_drawSelection:function(t,e){var o,i=this.s.dt,l=this.s.start,n=$(this.dom.start),t={row:this.c.vertical?i.rows({page:"current"}).nodes().indexOf(t.parentNode):l.row,column:this.c.horizontal?$(t).index():l.column},s=i.column.index("toData",t.column),a=i.row(":eq("+t.row+")",{page:"current"}),a=$(i.cell(a.index(),s).node());i.cell(a).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.outerHeight()-i,a=this._getPosition(l.get(0)).left+l.outerWidth()-o,(n=this.dom.select).top.css({top:i,left:o,width:a}),n.left.css({top:i,left:o,height:t}),n.bottom.css({top:i+t,left:o,width:a}),n.right.css({top:i,left:o+a,height:t}))},_editor:function(t){var e=this.s.dt,o=this.c.editor;if(o){for(var i={},l=[],n=o.fields(),s=0,a=t.length;s<a;s++)for(var d=0,c=t[s].length;d<c;d++){var r=t[s][d],u=e.settings()[0].aoColumns[r.index.column],h=u.editField;if(void 0===h)for(var f=u.mData,m=0,p=n.length;m<p;m++){var v=o.field(n[m]);if(v.dataSrc()===f){h=v.name();break}}if(!h)throw"Could not automatically determine field data. Please see https://datatables.net/tn/11";i[h]||(i[h]={});u=e.row(r.index.row).id();i[h][u]=r.set,l.push(r.index)}o.bubble(l,!1).multiSet(i).submit()}},_emitEvent:function(o,i){this.s.dt.iterator("table",function(t,e){$(t.nTable).triggerHandler(o+".dt",i)})},_focusListener:function(){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?($(e.table().body()).on("click"+t,"td, th",function(t){i._attach(this)}),$(document.body).on("click"+t,function(t){$(t.target).parents().filter(e.table().body()).length||i._detach()})):$(e.table().body()).on("mouseenter"+t+" touchstart"+t,"td, th",function(t){i._attach(this)}).on("mouseleave"+t+"touchend"+t,function(t){$(t.relatedTarget).hasClass("dt-autofill-handle")||i._detach()})},_focusListenerRemove:function(){var t=this.s.dt;t.off(".autoFill"),$(t.table().body()).off(this.s.namespace),$(document.body).off(this.s.namespace)},_getPosition:function(t,e){var o=t,i=0,l=0;e=e||$($(this.s.dt.table().node())[0].offsetParent);do{var n=o.offsetTop,s=o.offsetLeft,a=$(o.offsetParent)}while((i+=n+ +parseInt(a.css("border-top-width")||0),l+=s+ +parseInt(a.css("border-left-width")||0),"body"!==o.nodeName.toLowerCase())&&(o=a.get(0),a.get(0)!==e.get(0)));return{top:i,left:l}},_mousedown:function(t){var e=this,o=this.s.dt,i=(this.dom.start=this.dom.attachedTo,this.s.start={row:o.rows({page:"current"}).nodes().indexOf($(this.dom.start).parent()[0]),column:$(this.dom.start).index()},$(document.body).on("mousemove.autoFill touchmove.autoFill",function(t){e._mousemove(t),"touchmove"===t.type&&$(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).height(),windowWidth:$(window).width(),dtTop:i?i.offset().top:null,dtLeft:i?i.offset().left:null,dtHeight:i?i.outerHeight():null,dtWidth:i?i.outerWidth():null}},_mousemove:function(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:function(t){$(document.body).off(".autoFill");var e=this,l=this.s.dt,o=this.dom.select,o=(o.top.remove(),o.left.remove(),o.right.remove(),o.bottom.remove(),this.dom.handle.css("display","block"),this.s.start),i=this.s.end;if(o.row!==i.row||o.column!==i.column){var n,s=l.cell(":eq("+o.row+")",o.column+":visible",{page:"current"});if($("div.DTE",s.node()).length)(n=l.editor()).on("submitSuccess.dtaf close.dtaf",function(){n.off(".dtaf"),setTimeout(function(){e._mouseup(t)},100)}).on("submitComplete.dtaf preSubmitCancelled.dtaf close.dtaf",function(){n.off(".dtaf")}),n.submit();else{for(var a=this._range(o.row,i.row),d=this._range(o.column,i.column),c=[],r=l.settings()[0],u=r.aoColumns,h=l.columns(this.c.columns).indexes(),f=0;f<a.length;f++)c.push($.map(d,function(t){var e=l.row(":eq("+a[f]+")",{page:"current"}),e=l.cell(e.index(),t+":visible"),t=e.data(),o=e.index(),i=u[o.column].editField;if(void 0!==i&&(t=r.oApi._fnGetObjectDataFn(i)(l.row(o.row).data())),-1!==h.indexOf(o.column))return{cell:e,data:t,label:e.data(),index:o}}));this._actionSelector(c),clearInterval(this.s.scrollInterval),this.s.scrollInterval=null}}},_range:function(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:function(t){var e,o,i,l,n=this,s=(this.s.dt,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=n.dom.dtScroll[0],s.dtVert&&(t.scrollTop+=s.dtVert),s.dtHoriz&&(t.scrollLeft+=s.dtHoriz))},20))},_update:function(t,e){if(!1!==t){var o,t=this.s.dt,i=t.columns(this.c.columns).indexes();if(this._emitEvent("preAutoFill",[t,e]),this._editor(e),null!==this.c.update?this.c.update:!this.c.editor){for(var l=0,n=e.length;l<n;l++)for(var s=0,a=e[l].length;s<a;s++)o=e[l][s],-1!==i.indexOf(o.index.column)&&o.cell.data(o.set);t.draw(!1)}this._emitEvent("autoFill",[t,e])}}}),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,e,o){for(var i=+e[0][0].data,l=+$("input",o).val(),n=0,s=e.length;n<s;n++)for(var a=0,d=e[n].length;a<d;a++)e[n][a].set=i,i+=l}},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,e,o){for(var i=e[0][0].data,l=0,n=e.length;l<n;l++)for(var s=0,a=e[l].length;s<a;s++)e[l][s].set=i}},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,e,o){for(var i=0,l=e.length;i<l;i++)for(var n=0,s=e[i].length;n<s;n++)e[i][n].set=e[i][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,e,o){for(var i=0,l=e.length;i<l;i++)for(var n=0,s=e[i].length;n<s;n++)e[i][n].set=e[0][n].data}},cancel:{available:function(){return!1},option:function(t){return t.i18n("autoFill.cancel","Cancel")},execute:function(){return!1}}},AutoFill.version="2.5.3",AutoFill.defaults={alwaysAsk:!1,closeButton:!0,focus:null,columns:"",enable:!0,update:null,editor:null,vertical:!0,horizontal:!0},AutoFill.classes={btn:"btn",closeable:"dtaf-popover-closeable"},$.fn.dataTable.Api);Api.register("autoFill()",function(){return this}),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()})}),$(document).on("preInit.dt.autofill",function(t,e,o){var i;"dt"===t.namespace&&(t=e.oInit.autoFill,i=DataTable.defaults.autoFill,(t||i)&&(i=$.extend({},t,i),!1!==t&&new AutoFill(e,i)))}),DataTable.AutoFill=AutoFill,$.fn.DataTable.AutoFill=AutoFill;export default DataTable;
|
|
4
|
+
import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;var _instance=0,AutoFill=function(t,e){if(!DataTable.versionCheck||!DataTable.versionCheck("1.11"))throw"Warning: AutoFill requires DataTables 1.11 or greater";this.c=$.extend(!0,{},DataTable.defaults.autoFill,AutoFill.defaults,e),this.s={dt:new DataTable.Api(t),namespace:".autoFill"+_instance++,scroll:{},scrollInterval:null,handle:{height:0,width:0},enabled:!1},this.dom={closeButton:$('<div class="dtaf-popover-close">×</div>'),handle:$('<div class="dt-autofill-handle"/>'),select:{top:$('<div class="dt-autofill-select top"/>'),right:$('<div class="dt-autofill-select right"/>'),bottom:$('<div class="dt-autofill-select bottom"/>'),left:$('<div class="dt-autofill-select left"/>')},background:$('<div class="dt-autofill-background"/>'),list:$('<div class="dt-autofill-list">'+this.s.dt.i18n("autoFill.info","")+"</div>").attr("aria-modal",!0).attr("role","dialog").append('<div class="dt-autofill-list-items"></div>'),dtScroll:null,offsetParent:null},this._constructor()},Api=($.extend(AutoFill.prototype,{enabled:function(){return this.s.enabled},enable:function(t){var e=this;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}),$(window).on("resize",function(){0<$("div.dt-autofill-handle").length&&void 0!==e.dom.attachedTo&&e._attach(e.dom.attachedTo)});function o(){e.s.handle={height:!1,width:!1},$(e.dom.handle).css({height:"",width:""}),void 0!==e.dom.attachedTo&&e._attach(e.dom.attachedTo)}return $(window).on("orientationchange",function(){setTimeout(function(){o(),setTimeout(o,150)},50)}),this},disable:function(){return this.s.enabled=!1,this._focusListenerRemove(),this},_constructor:function(){var t=this,e=this.s.dt,o=$("div.dataTables_scrollBody",this.s.dt.table().container());e.settings()[0].autoFill=this,o.length&&"static"===(this.dom.dtScroll=o).css("position")&&o.css("position","relative"),!1!==this.c.enable&&this.enable(),e.on("destroy.autoFill",function(){t._focusListenerRemove()})},_attach:function(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.outerHeight(),l.width=i.outerWidth()),o=this._getPosition(t,this.dom.offsetParent),this.dom.attachedTo=t,i.css({top:o.top+t.offsetHeight-l.height,left:o.left+t.offsetWidth-l.width}).appendTo(this.dom.offsetParent)):this._detach()},_actionSelector:function(o){var t,i,l=this,n=this.s.dt,s=AutoFill.actions,a=[];$.each(s,function(t,e){e.available(n,o)&&a.push(t)}),1===a.length&&!1===this.c.alwaysAsk?(t=s[a[0]].execute(n,o),this._update(t,o)):(1<a.length||this.c.alwaysAsk)&&(i=this.dom.list.children("div.dt-autofill-list-items").empty(),a.push("cancel"),$.each(a,function(t,e){i.append($("<button/>").html(s[e].option(n,o)).append($('<span class="dt-autofill-button"/>').html(n.i18n("autoFill.button",">"))).on("click",function(t){"button"===t.target.nodeName.toLowerCase()&&(t=s[e].execute(n,o,$(this).closest("button")),l._update(t,o),l.dom.background.remove(),l.dom.list.remove())}))}),this.dom.background.appendTo("body"),this.dom.background.one("click",function(){l.dom.background.remove(),l.dom.list.remove()}),this.dom.list.appendTo("body"),this.c.closeButton&&(this.dom.list.prepend(this.dom.closeButton).addClass(AutoFill.classes.closeable),this.dom.closeButton.on("click",function(){return l.dom.background.click()})),this.dom.list.css("margin-top",this.dom.list.outerHeight()/2*-1))},_detach:function(){this.dom.attachedTo=null,this.dom.handle.detach()},_drawSelection:function(t,e){var o,i=this.s.dt,l=this.s.start,n=$(this.dom.start),t={row:this.c.vertical?i.rows({page:"current"}).nodes().indexOf(t.parentNode):l.row,column:this.c.horizontal?$(t).index():l.column},s=i.column.index("toData",t.column),a=i.row(":eq("+t.row+")",{page:"current"}),a=$(i.cell(a.index(),s).node());i.cell(a).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.outerHeight()-i,a=this._getPosition(l.get(0)).left+l.outerWidth()-o,(n=this.dom.select).top.css({top:i,left:o,width:a}),n.left.css({top:i,left:o,height:t}),n.bottom.css({top:i+t,left:o,width:a}),n.right.css({top:i,left:o+a,height:t}))},_editor:function(t){var e=this.s.dt,o=this.c.editor;if(o){for(var i={},l=[],n=o.fields(),s=0,a=t.length;s<a;s++)for(var d=0,r=t[s].length;d<r;d++){var c=t[s][d],u=e.settings()[0].aoColumns[c.index.column],h=u.editField;if(void 0===h)for(var f=u.mData,m=0,p=n.length;m<p;m++){var v=o.field(n[m]);if(v.dataSrc()===f){h=v.name();break}}if(!h)throw"Could not automatically determine field data. Please see https://datatables.net/tn/11";i[h]||(i[h]={});u=e.row(c.index.row).id();i[h][u]=c.set,l.push(c.index)}o.bubble(l,!1).multiSet(i).submit(null,function(){o.close()})}},_emitEvent:function(o,i){this.s.dt.iterator("table",function(t,e){$(t.nTable).triggerHandler(o+".dt",i)})},_focusListener:function(){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?($(e.table().body()).on("click"+t,"td, th",function(t){i._attach(this)}),$(document.body).on("click"+t,function(t){$(t.target).parents().filter(e.table().body()).length||i._detach()})):$(e.table().body()).on("mouseenter"+t+" touchstart"+t,"td, th",function(t){i._attach(this)}).on("mouseleave"+t+"touchend"+t,function(t){$(t.relatedTarget).hasClass("dt-autofill-handle")||i._detach()})},_focusListenerRemove:function(){var t=this.s.dt;t.off(".autoFill"),$(t.table().body()).off(this.s.namespace),$(document.body).off(this.s.namespace)},_getPosition:function(t,e){var o=t,i=0,l=0;e=e||$($(this.s.dt.table().node())[0].offsetParent);do{var n=o.offsetTop,s=o.offsetLeft,a=$(o.offsetParent)}while((i+=n+ +parseInt(a.css("border-top-width")||0),l+=s+ +parseInt(a.css("border-left-width")||0),"body"!==o.nodeName.toLowerCase())&&(o=a.get(0),a.get(0)!==e.get(0)));return{top:i,left:l}},_mousedown:function(t){var e=this,o=this.s.dt,i=(this.dom.start=this.dom.attachedTo,this.s.start={row:o.rows({page:"current"}).nodes().indexOf($(this.dom.start).parent()[0]),column:$(this.dom.start).index()},$(document.body).on("mousemove.autoFill touchmove.autoFill",function(t){e._mousemove(t),"touchmove"===t.type&&$(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).height(),windowWidth:$(window).width(),dtTop:i?i.offset().top:null,dtLeft:i?i.offset().left:null,dtHeight:i?i.outerHeight():null,dtWidth:i?i.outerWidth():null}},_mousemove:function(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:function(t){$(document.body).off(".autoFill");var e=this,l=this.s.dt,o=this.dom.select,o=(o.top.remove(),o.left.remove(),o.right.remove(),o.bottom.remove(),this.dom.handle.css("display","block"),this.s.start),i=this.s.end;if(o.row!==i.row||o.column!==i.column){var n,s=l.cell(":eq("+o.row+")",o.column+":visible",{page:"current"});if($("div.DTE",s.node()).length)(n=l.editor()).on("submitSuccess.dtaf close.dtaf",function(){n.off(".dtaf"),setTimeout(function(){e._mouseup(t)},100)}).on("submitComplete.dtaf preSubmitCancelled.dtaf close.dtaf",function(){n.off(".dtaf")}),n.submit();else{for(var a=this._range(o.row,i.row),d=this._range(o.column,i.column),r=[],c=l.settings()[0].aoColumns,u=l.columns(this.c.columns).indexes(),h=0;h<a.length;h++)r.push($.map(d,function(t){var e=l.row(":eq("+a[h]+")",{page:"current"}),e=l.cell(e.index(),t+":visible"),t=e.data(),o=e.index(),i=c[o.column].editField;if(void 0!==i&&(t=DataTable.util.get(i)(l.row(o.row).data())),-1!==u.indexOf(o.column))return{cell:e,data:t,label:e.data(),index:o}}));this._actionSelector(r),clearInterval(this.s.scrollInterval),this.s.scrollInterval=null}}},_range:function(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:function(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=n.dom.dtScroll[0],s.dtVert&&(t.scrollTop+=s.dtVert),s.dtHoriz)&&(t.scrollLeft+=s.dtHoriz)},20))},_update:function(t,e){if(!1!==t){var o,t=this.s.dt,i=t.columns(this.c.columns).indexes();if(this._emitEvent("preAutoFill",[t,e]),this._editor(e),null!==this.c.update?this.c.update:!this.c.editor){for(var l=0,n=e.length;l<n;l++)for(var s=0,a=e[l].length;s<a;s++)o=e[l][s],-1!==i.indexOf(o.index.column)&&o.cell.data(o.set);t.draw(!1)}this._emitEvent("autoFill",[t,e])}}}),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,e,o){for(var i=+e[0][0].data,l=+$("input",o).val(),n=0,s=e.length;n<s;n++)for(var a=0,d=e[n].length;a<d;a++)e[n][a].set=i,i+=l}},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,e,o){for(var i=e[0][0].data,l=0,n=e.length;l<n;l++)for(var s=0,a=e[l].length;s<a;s++)e[l][s].set=i}},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,e,o){for(var i=0,l=e.length;i<l;i++)for(var n=0,s=e[i].length;n<s;n++)e[i][n].set=e[i][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,e,o){for(var i=0,l=e.length;i<l;i++)for(var n=0,s=e[i].length;n<s;n++)e[i][n].set=e[0][n].data}},cancel:{available:function(){return!1},option:function(t){return t.i18n("autoFill.cancel","Cancel")},execute:function(){return!1}}},AutoFill.version="2.7.0",AutoFill.defaults={alwaysAsk:!1,closeButton:!0,focus:null,columns:"",enable:!0,update:null,editor:null,vertical:!0,horizontal:!0},AutoFill.classes={btn:"btn",closeable:"dtaf-popover-closeable"},$.fn.dataTable.Api);Api.register("autoFill()",function(){return this}),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()})}),$(document).on("preInit.dt.autofill",function(t,e,o){var i,l;"dt"===t.namespace&&(t=e.oInit.autoFill,i=DataTable.defaults.autoFill,t||i)&&(l=$.extend({},t,i),!1!==t)&&new AutoFill(e,l)}),DataTable.AutoFill=AutoFill,$.fn.DataTable.AutoFill=AutoFill;export default DataTable;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
/*! AutoFill 2.
|
|
2
|
-
* ©
|
|
1
|
+
/*! AutoFill 2.7.0
|
|
2
|
+
* © SpryMedia Ltd - datatables.net/license
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import jQuery from 'jquery';
|
|
6
6
|
import DataTable from 'datatables.net';
|
|
7
7
|
|
|
8
|
+
// Allow reassignment of the $ variable
|
|
9
|
+
let $ = jQuery;
|
|
10
|
+
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* @summary AutoFill
|
|
11
14
|
* @description Add Excel like click and drag auto-fill options to DataTables
|
|
12
|
-
* @version 2.
|
|
15
|
+
* @version 2.7.0
|
|
13
16
|
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
|
14
17
|
* @copyright SpryMedia Ltd.
|
|
15
18
|
*
|
|
@@ -35,8 +38,8 @@ var _instance = 0;
|
|
|
35
38
|
*/
|
|
36
39
|
var AutoFill = function( dt, opts )
|
|
37
40
|
{
|
|
38
|
-
if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.
|
|
39
|
-
throw( "Warning: AutoFill requires DataTables 1.
|
|
41
|
+
if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.11' ) ) {
|
|
42
|
+
throw( "Warning: AutoFill requires DataTables 1.11 or greater");
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
// User and defaults configuration object
|
|
@@ -79,7 +82,7 @@ var AutoFill = function( dt, opts )
|
|
|
79
82
|
* @namespace Common and useful DOM elements for the class instance
|
|
80
83
|
*/
|
|
81
84
|
this.dom = {
|
|
82
|
-
closeButton: $('<div class="dtaf-popover-close"
|
|
85
|
+
closeButton: $('<div class="dtaf-popover-close">×</div>'),
|
|
83
86
|
|
|
84
87
|
/** @type {jQuery} AutoFill handle */
|
|
85
88
|
handle: $('<div class="dt-autofill-handle"/>'),
|
|
@@ -100,7 +103,10 @@ var AutoFill = function( dt, opts )
|
|
|
100
103
|
background: $('<div class="dt-autofill-background"/>'),
|
|
101
104
|
|
|
102
105
|
/** @type {jQuery} Fill type chooser */
|
|
103
|
-
list: $('<div class="dt-autofill-list">'+this.s.dt.i18n('autoFill.info', '')+'
|
|
106
|
+
list: $('<div class="dt-autofill-list">'+this.s.dt.i18n('autoFill.info', '')+'</div>')
|
|
107
|
+
.attr('aria-modal', true)
|
|
108
|
+
.attr('role', 'dialog')
|
|
109
|
+
.append('<div class="dt-autofill-list-items"></div>'),
|
|
104
110
|
|
|
105
111
|
/** @type {jQuery} DataTables scrolling container */
|
|
106
112
|
dtScroll: null,
|
|
@@ -298,24 +304,24 @@ $.extend( AutoFill.prototype, {
|
|
|
298
304
|
var result = actions[ available[0] ].execute( dt, cells );
|
|
299
305
|
this._update( result, cells );
|
|
300
306
|
}
|
|
301
|
-
else if ( available.length > 1 ) {
|
|
307
|
+
else if ( available.length > 1 || this.c.alwaysAsk ) {
|
|
302
308
|
// Multiple actions available - ask the end user what they want to do
|
|
303
|
-
var list = this.dom.list.children('
|
|
309
|
+
var list = this.dom.list.children('div.dt-autofill-list-items').empty();
|
|
304
310
|
|
|
305
311
|
// Add a cancel option
|
|
306
312
|
available.push( 'cancel' );
|
|
307
313
|
|
|
308
314
|
$.each( available, function ( i, name ) {
|
|
309
|
-
list.append( $('<
|
|
310
|
-
.
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
'
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
315
|
+
list.append( $('<button/>')
|
|
316
|
+
.html(actions[ name ].option( dt, cells ))
|
|
317
|
+
.append( $('<span class="dt-autofill-button"/>').html(dt.i18n('autoFill.button', '>')))
|
|
318
|
+
.on( 'click', function (e) {
|
|
319
|
+
if (e.target.nodeName.toLowerCase() !== 'button') {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
|
|
317
323
|
var result = actions[ name ].execute(
|
|
318
|
-
dt, cells, $(this).closest('
|
|
324
|
+
dt, cells, $(this).closest('button')
|
|
319
325
|
);
|
|
320
326
|
that._update( result, cells );
|
|
321
327
|
|
|
@@ -502,7 +508,11 @@ $.extend( AutoFill.prototype, {
|
|
|
502
508
|
editor
|
|
503
509
|
.bubble( nodes, false )
|
|
504
510
|
.multiSet( idValues )
|
|
505
|
-
.submit()
|
|
511
|
+
.submit(null, function () {
|
|
512
|
+
// If an error happens, Editor will show an alert, and then we need
|
|
513
|
+
// to finish the edit since we can't do anything else.
|
|
514
|
+
editor.close();
|
|
515
|
+
});
|
|
506
516
|
},
|
|
507
517
|
|
|
508
518
|
|
|
@@ -791,7 +801,7 @@ $.extend( AutoFill.prototype, {
|
|
|
791
801
|
var editField = dtColumns[ cellIndex.column ].editField;
|
|
792
802
|
|
|
793
803
|
if ( editField !== undefined ) {
|
|
794
|
-
data =
|
|
804
|
+
data = DataTable.util.get( editField )( dt.row( cellIndex.row ).data() );
|
|
795
805
|
}
|
|
796
806
|
|
|
797
807
|
if ( enabledColumns.indexOf(cellIndex.column) === -1 ) {
|
|
@@ -858,7 +868,6 @@ $.extend( AutoFill.prototype, {
|
|
|
858
868
|
_shiftScroll: function ( e )
|
|
859
869
|
{
|
|
860
870
|
var that = this;
|
|
861
|
-
var dt = this.s.dt;
|
|
862
871
|
var scroll = this.s.scroll;
|
|
863
872
|
var runInterval = false;
|
|
864
873
|
var scrollSpeed = 5;
|
|
@@ -1123,7 +1132,7 @@ AutoFill.actions = {
|
|
|
1123
1132
|
* @static
|
|
1124
1133
|
* @type String
|
|
1125
1134
|
*/
|
|
1126
|
-
AutoFill.version = '2.
|
|
1135
|
+
AutoFill.version = '2.7.0';
|
|
1127
1136
|
|
|
1128
1137
|
|
|
1129
1138
|
/**
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "js/dataTables.autoFill.js",
|
|
5
5
|
"module": "js/dataTables.autoFill.mjs",
|
|
6
6
|
"types": "./types/types.d.ts",
|
|
7
|
-
"version": "2.
|
|
7
|
+
"version": "2.7.0",
|
|
8
8
|
"files": [
|
|
9
9
|
"js/**/*.js",
|
|
10
10
|
"js/**/*.mjs",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"sort"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"datatables.net": ">=1.
|
|
23
|
+
"datatables.net": ">=1.11",
|
|
24
24
|
"jquery": ">=1.7"
|
|
25
25
|
},
|
|
26
26
|
"moduleType": [
|
package/types/types.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import DataTables, {Api} from 'datatables.net';
|
|
11
11
|
|
|
12
12
|
export default DataTables;
|
|
13
|
-
|
|
13
|
+
export * from 'datatables.net';
|
|
14
14
|
|
|
15
15
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
16
16
|
* DataTables' types integration
|
|
@@ -39,7 +39,7 @@ declare module 'datatables.net' {
|
|
|
39
39
|
autoFill: ApiAutoFill<T>;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
interface
|
|
42
|
+
interface DataTablesStatic {
|
|
43
43
|
/**
|
|
44
44
|
* AutoFill class
|
|
45
45
|
*/
|
|
@@ -47,7 +47,7 @@ declare module 'datatables.net' {
|
|
|
47
47
|
/**
|
|
48
48
|
* Create a new AutoFill instance for the target DataTable
|
|
49
49
|
*/
|
|
50
|
-
new (dt: Api<any>, settings: boolean | ConfigAutoFill);
|
|
50
|
+
new (dt: Api<any>, settings: boolean | ConfigAutoFill): AutoFill;
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* AutoFill version
|