datatables.net-autofill 2.4.0 → 2.5.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.
- package/js/dataTables.autoFill.js +62 -42
- package/js/dataTables.autoFill.min.js +4 -50
- package/js/dataTables.autoFill.min.mjs +4 -0
- package/js/dataTables.autoFill.mjs +1237 -0
- package/package.json +4 -2
- package/types/types.d.ts +179 -63
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
/*! AutoFill 2.3.9
|
|
2
|
-
* ©2008-2021 SpryMedia Ltd - datatables.net/license
|
|
3
|
-
*/
|
|
4
1
|
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* @description Add Excel like click and drag auto-fill options to DataTables
|
|
8
|
-
* @version 2.3.9
|
|
9
|
-
* @file dataTables.autoFill.js
|
|
10
|
-
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
|
11
|
-
* @contact www.sprymedia.co.uk/contact
|
|
12
|
-
* @copyright Copyright 2010-2021 SpryMedia Ltd.
|
|
13
|
-
*
|
|
14
|
-
* This source file is free software, available under the following license:
|
|
15
|
-
* MIT license - http://datatables.net/license/mit
|
|
16
|
-
*
|
|
17
|
-
* This source file is distributed in the hope that it will be useful, but
|
|
18
|
-
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
19
|
-
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
|
|
20
|
-
*
|
|
21
|
-
* For details please refer to: http://www.datatables.net
|
|
2
|
+
/*! AutoFill 2.5.0
|
|
3
|
+
* ©2008-2022 SpryMedia Ltd - datatables.net/license
|
|
22
4
|
*/
|
|
5
|
+
|
|
23
6
|
(function( factory ){
|
|
24
7
|
if ( typeof define === 'function' && define.amd ) {
|
|
25
8
|
// AMD
|
|
@@ -31,13 +14,22 @@
|
|
|
31
14
|
// CommonJS
|
|
32
15
|
module.exports = function (root, $) {
|
|
33
16
|
if ( ! root ) {
|
|
17
|
+
// CommonJS environments without a window global must pass a
|
|
18
|
+
// root. This will give an error otherwise
|
|
34
19
|
root = window;
|
|
35
20
|
}
|
|
36
21
|
|
|
37
|
-
if ( ! $
|
|
38
|
-
$ =
|
|
22
|
+
if ( ! $ ) {
|
|
23
|
+
$ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
|
|
24
|
+
require('jquery') :
|
|
25
|
+
require('jquery')( root );
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if ( ! $.fn.dataTable ) {
|
|
29
|
+
require('datatables.net')(root, $);
|
|
39
30
|
}
|
|
40
31
|
|
|
32
|
+
|
|
41
33
|
return factory( $, root, root.document );
|
|
42
34
|
};
|
|
43
35
|
}
|
|
@@ -50,6 +42,24 @@
|
|
|
50
42
|
var DataTable = $.fn.dataTable;
|
|
51
43
|
|
|
52
44
|
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @summary AutoFill
|
|
48
|
+
* @description Add Excel like click and drag auto-fill options to DataTables
|
|
49
|
+
* @version 2.5.0
|
|
50
|
+
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
|
51
|
+
* @copyright SpryMedia Ltd.
|
|
52
|
+
*
|
|
53
|
+
* This source file is free software, available under the following license:
|
|
54
|
+
* MIT license - http://datatables.net/license/mit
|
|
55
|
+
*
|
|
56
|
+
* This source file is distributed in the hope that it will be useful, but
|
|
57
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
58
|
+
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
|
|
59
|
+
*
|
|
60
|
+
* For details please refer to: http://www.datatables.net
|
|
61
|
+
*/
|
|
62
|
+
|
|
53
63
|
var _instance = 0;
|
|
54
64
|
|
|
55
65
|
/**
|
|
@@ -106,6 +116,8 @@ var AutoFill = function( dt, opts )
|
|
|
106
116
|
* @namespace Common and useful DOM elements for the class instance
|
|
107
117
|
*/
|
|
108
118
|
this.dom = {
|
|
119
|
+
closeButton: $('<div class="dtaf-popover-close">x</div>'),
|
|
120
|
+
|
|
109
121
|
/** @type {jQuery} AutoFill handle */
|
|
110
122
|
handle: $('<div class="dt-autofill-handle"/>'),
|
|
111
123
|
|
|
@@ -337,29 +349,33 @@ $.extend( AutoFill.prototype, {
|
|
|
337
349
|
actions[ name ].option( dt, cells )+
|
|
338
350
|
'<div>'
|
|
339
351
|
)
|
|
340
|
-
.append( $('<div class="dt-autofill-button">' )
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
} )
|
|
351
|
-
)
|
|
352
|
-
)
|
|
352
|
+
.append( $('<div class="dt-autofill-button">' ).append( $('<button class="'+AutoFill.classes.btn+'">'+dt.i18n('autoFill.button', '>')+'</button>')))
|
|
353
|
+
.on( 'click', function () {
|
|
354
|
+
var result = actions[ name ].execute(
|
|
355
|
+
dt, cells, $(this).closest('li')
|
|
356
|
+
);
|
|
357
|
+
that._update( result, cells );
|
|
358
|
+
|
|
359
|
+
that.dom.background.remove();
|
|
360
|
+
that.dom.list.remove();
|
|
361
|
+
} )
|
|
353
362
|
);
|
|
354
363
|
} );
|
|
355
364
|
|
|
356
365
|
this.dom.background.appendTo( 'body' );
|
|
357
|
-
this.dom.background.one('click', ()
|
|
358
|
-
|
|
359
|
-
|
|
366
|
+
this.dom.background.one('click', function() {
|
|
367
|
+
that.dom.background.remove();
|
|
368
|
+
that.dom.list.remove();
|
|
360
369
|
})
|
|
361
370
|
this.dom.list.appendTo( 'body' );
|
|
362
371
|
|
|
372
|
+
if (this.c.closeButton) {
|
|
373
|
+
this.dom.list.prepend(this.dom.closeButton).addClass(AutoFill.classes.closeable)
|
|
374
|
+
this.dom.closeButton.on('click', function() {
|
|
375
|
+
return that.dom.background.click()
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
363
379
|
this.dom.list.css( 'margin-top', this.dom.list.outerHeight()/2 * -1 );
|
|
364
380
|
}
|
|
365
381
|
},
|
|
@@ -1102,7 +1118,7 @@ AutoFill.actions = {
|
|
|
1102
1118
|
|
|
1103
1119
|
fillVertical: {
|
|
1104
1120
|
available: function ( dt, cells ) {
|
|
1105
|
-
return cells.length > 1;
|
|
1121
|
+
return cells.length > 1 && cells[0].length > 1;
|
|
1106
1122
|
},
|
|
1107
1123
|
|
|
1108
1124
|
option: function ( dt, cells ) {
|
|
@@ -1143,7 +1159,7 @@ AutoFill.actions = {
|
|
|
1143
1159
|
* @static
|
|
1144
1160
|
* @type String
|
|
1145
1161
|
*/
|
|
1146
|
-
AutoFill.version = '2.
|
|
1162
|
+
AutoFill.version = '2.5.0';
|
|
1147
1163
|
|
|
1148
1164
|
|
|
1149
1165
|
/**
|
|
@@ -1155,6 +1171,8 @@ AutoFill.defaults = {
|
|
|
1155
1171
|
/** @type {Boolean} Ask user what they want to do, even for a single option */
|
|
1156
1172
|
alwaysAsk: false,
|
|
1157
1173
|
|
|
1174
|
+
closeButton: true,
|
|
1175
|
+
|
|
1158
1176
|
/** @type {string|null} What will trigger a focus */
|
|
1159
1177
|
focus: null, // focus, click, hover
|
|
1160
1178
|
|
|
@@ -1185,7 +1203,9 @@ AutoFill.defaults = {
|
|
|
1185
1203
|
*/
|
|
1186
1204
|
AutoFill.classes = {
|
|
1187
1205
|
/** @type {String} Class used by the selection button */
|
|
1188
|
-
btn: 'btn'
|
|
1206
|
+
btn: 'btn',
|
|
1207
|
+
|
|
1208
|
+
closeable: 'dtaf-popover-closeable'
|
|
1189
1209
|
};
|
|
1190
1210
|
|
|
1191
1211
|
|
|
@@ -1249,5 +1269,5 @@ DataTable.AutoFill = AutoFill;
|
|
|
1249
1269
|
DataTable.AutoFill = AutoFill;
|
|
1250
1270
|
|
|
1251
1271
|
|
|
1252
|
-
return
|
|
1272
|
+
return DataTable;
|
|
1253
1273
|
}));
|
|
@@ -1,50 +1,4 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
This source file is free software, available under the following license:
|
|
5
|
-
MIT license - http://datatables.net/license/mit
|
|
6
|
-
|
|
7
|
-
This source file is distributed in the hope that it will be useful, but
|
|
8
|
-
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
9
|
-
or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
|
|
10
|
-
|
|
11
|
-
For details please refer to: http://www.datatables.net
|
|
12
|
-
AutoFill 2.3.9
|
|
13
|
-
©2008-2021 SpryMedia Ltd - datatables.net/license
|
|
14
|
-
*/
|
|
15
|
-
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(b){var f=0;return function(){return f<b.length?{done:!1,value:b[f++]}:{done:!0}}};$jscomp.arrayIterator=function(b){return{next:$jscomp.arrayIteratorImpl(b)}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;
|
|
16
|
-
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(b,f,g){if(b==Array.prototype||b==Object.prototype)return b;b[f]=g.value;return b};$jscomp.getGlobal=function(b){b=["object"==typeof globalThis&&globalThis,b,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var f=0;f<b.length;++f){var g=b[f];if(g&&g.Math==Math)return g}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
|
|
17
|
-
$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(b,f){var g=$jscomp.propertyToPolyfillSymbol[f];if(null==g)return b[f];g=b[g];return void 0!==g?g:b[f]};
|
|
18
|
-
$jscomp.polyfill=function(b,f,g,k){f&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(b,f,g,k):$jscomp.polyfillUnisolated(b,f,g,k))};$jscomp.polyfillUnisolated=function(b,f,g,k){g=$jscomp.global;b=b.split(".");for(k=0;k<b.length-1;k++){var m=b[k];if(!(m in g))return;g=g[m]}b=b[b.length-1];k=g[b];f=f(k);f!=k&&null!=f&&$jscomp.defineProperty(g,b,{configurable:!0,writable:!0,value:f})};
|
|
19
|
-
$jscomp.polyfillIsolated=function(b,f,g,k){var m=b.split(".");b=1===m.length;k=m[0];k=!b&&k in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var v=0;v<m.length-1;v++){var q=m[v];if(!(q in k))return;k=k[q]}m=m[m.length-1];g=$jscomp.IS_SYMBOL_NATIVE&&"es6"===g?k[m]:null;f=f(g);null!=f&&(b?$jscomp.defineProperty($jscomp.polyfills,m,{configurable:!0,writable:!0,value:f}):f!==g&&($jscomp.propertyToPolyfillSymbol[m]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(m):$jscomp.POLYFILL_PREFIX+m,m=
|
|
20
|
-
$jscomp.propertyToPolyfillSymbol[m],$jscomp.defineProperty(k,m,{configurable:!0,writable:!0,value:f})))};$jscomp.initSymbol=function(){};
|
|
21
|
-
$jscomp.polyfill("Symbol",function(b){if(b)return b;var f=function(m,v){this.$jscomp$symbol$id_=m;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:v})};f.prototype.toString=function(){return this.$jscomp$symbol$id_};var g=0,k=function(m){if(this instanceof k)throw new TypeError("Symbol is not a constructor");return new f("jscomp_symbol_"+(m||"")+"_"+g++,m)};return k},"es6","es3");$jscomp.initSymbolIterator=function(){};
|
|
22
|
-
$jscomp.polyfill("Symbol.iterator",function(b){if(b)return b;b=Symbol("Symbol.iterator");for(var f="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),g=0;g<f.length;g++){var k=$jscomp.global[f[g]];"function"===typeof k&&"function"!=typeof k.prototype[b]&&$jscomp.defineProperty(k.prototype,b,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}})}return b},"es6",
|
|
23
|
-
"es3");$jscomp.initSymbolAsyncIterator=function(){};$jscomp.iteratorPrototype=function(b){b={next:b};b[Symbol.iterator]=function(){return this};return b};$jscomp.iteratorFromArray=function(b,f){b instanceof String&&(b+="");var g=0,k={next:function(){if(g<b.length){var m=g++;return{value:f(m,b[m]),done:!1}}k.next=function(){return{done:!0,value:void 0}};return k.next()}};k[Symbol.iterator]=function(){return k};return k};
|
|
24
|
-
$jscomp.polyfill("Array.prototype.keys",function(b){return b?b:function(){return $jscomp.iteratorFromArray(this,function(f){return f})}},"es6","es3");$jscomp.polyfill("Object.is",function(b){return b?b:function(f,g){return f===g?0!==f||1/f===1/g:f!==f&&g!==g}},"es6","es3");
|
|
25
|
-
$jscomp.polyfill("Array.prototype.includes",function(b){return b?b:function(f,g){var k=this;k instanceof String&&(k=String(k));var m=k.length;g=g||0;for(0>g&&(g=Math.max(g+m,0));g<m;g++){var v=k[g];if(v===f||Object.is(v,f))return!0}return!1}},"es7","es3");
|
|
26
|
-
$jscomp.checkStringArgs=function(b,f,g){if(null==b)throw new TypeError("The 'this' value for String.prototype."+g+" must not be null or undefined");if(f instanceof RegExp)throw new TypeError("First argument to String.prototype."+g+" must not be a regular expression");return b+""};$jscomp.polyfill("String.prototype.includes",function(b){return b?b:function(f,g){return-1!==$jscomp.checkStringArgs(this,f,"includes").indexOf(f,g||0)}},"es6","es3");
|
|
27
|
-
(function(b){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(f){return b(f,window,document)}):"object"===typeof exports?module.exports=function(f,g){f||(f=window);g&&g.fn.dataTable||(g=require("datatables.net")(f,g).$);return b(g,f,f.document)}:b(jQuery,window,document)})(function(b,f,g,k){var m=b.fn.dataTable,v=0,q=function(a,d){if(!m.versionCheck||!m.versionCheck("1.10.8"))throw"Warning: AutoFill requires DataTables 1.10.8 or greater";this.c=b.extend(!0,{},m.defaults.autoFill,
|
|
28
|
-
q.defaults,d);this.s={dt:new m.Api(a),namespace:".autoFill"+v++,scroll:{},scrollInterval:null,handle:{height:0,width:0},enabled:!1};this.dom={handle:b('<div class="dt-autofill-handle"/>'),select:{top:b('<div class="dt-autofill-select top"/>'),right:b('<div class="dt-autofill-select right"/>'),bottom:b('<div class="dt-autofill-select bottom"/>'),left:b('<div class="dt-autofill-select left"/>')},background:b('<div class="dt-autofill-background"/>'),list:b('<div class="dt-autofill-list">'+this.s.dt.i18n("autoFill.info",
|
|
29
|
-
"")+"<ul/></div>"),dtScroll:null,offsetParent:null};this._constructor()};b.extend(q.prototype,{enabled:function(){return this.s.enabled},enable:function(a){var d=this;if(!1===a)return this.disable();this.s.enabled=!0;this._focusListener();this.dom.handle.on("mousedown touchstart",function(e){d._mousedown(e);return!1});b(f).on("resize",function(){0<b("div.dt-autofill-handle").length&&d.dom.attachedTo!==k&&d._attach(d.dom.attachedTo)});var c=function(){d.s.handle={height:!1,width:!1};b(d.dom.handle).css({height:"",
|
|
30
|
-
width:""});d.dom.attachedTo!==k&&d._attach(d.dom.attachedTo)};b(f).on("orientationchange",function(){setTimeout(function(){c();setTimeout(c,150)},50)});return this},disable:function(){this.s.enabled=!1;this._focusListenerRemove();return this},_constructor:function(){var a=this,d=this.s.dt,c=b("div.dataTables_scrollBody",this.s.dt.table().container());d.settings()[0].autoFill=this;c.length&&(this.dom.dtScroll=c,"static"===c.css("position")&&c.css("position","relative"));!1!==this.c.enable&&this.enable();
|
|
31
|
-
d.on("destroy.autoFill",function(){a._focusListenerRemove()})},_attach:function(a){var d=this.s.dt,c=d.cell(a).index(),e=this.dom.handle,h=this.s.handle;c&&-1!==d.columns(this.c.columns).indexes().indexOf(c.column)?(this.dom.offsetParent||(this.dom.offsetParent=b(d.table().node()).offsetParent()),h.height&&h.width||(e.appendTo("body"),h.height=e.outerHeight(),h.width=e.outerWidth()),d=this._getPosition(a,this.dom.offsetParent),this.dom.attachedTo=a,e.css({top:d.top+a.offsetHeight-h.height,left:d.left+
|
|
32
|
-
a.offsetWidth-h.width}).appendTo(this.dom.offsetParent)):this._detach()},_actionSelector:function(a){var d=this,c=this,e=this.s.dt,h=q.actions,l=[];b.each(h,function(r,t){t.available(e,a)&&l.push(r)});if(1===l.length&&!1===this.c.alwaysAsk){var n=h[l[0]].execute(e,a);this._update(n,a)}else if(1<l.length){var p=this.dom.list.children("ul").empty();l.push("cancel");b.each(l,function(r,t){p.append(b("<li/>").append('<div class="dt-autofill-question">'+h[t].option(e,a)+"<div>").append(b('<div class="dt-autofill-button">').append(b('<button class="'+
|
|
33
|
-
q.classes.btn+'">'+e.i18n("autoFill.button",">")+"</button>").on("click",function(){var x=h[t].execute(e,a,b(this).closest("li"));c._update(x,a);c.dom.background.remove();c.dom.list.remove()}))))});this.dom.background.appendTo("body");this.dom.background.one("click",function(){d.dom.background.remove();d.dom.list.remove()});this.dom.list.appendTo("body");this.dom.list.css("margin-top",this.dom.list.outerHeight()/2*-1)}},_detach:function(){this.dom.attachedTo=null;this.dom.handle.detach()},_drawSelection:function(a,
|
|
34
|
-
d){var c=this.s.dt;d=this.s.start;var e=b(this.dom.start),h={row:this.c.vertical?c.rows({page:"current"}).nodes().indexOf(a.parentNode):d.row,column:this.c.horizontal?b(a).index():d.column};a=c.column.index("toData",h.column);var l=c.row(":eq("+h.row+")",{page:"current"});l=b(c.cell(l.index(),a).node());if(c.cell(l).any()&&-1!==c.columns(this.c.columns).indexes().indexOf(a)&&-1!==h.row){this.s.end=h;c=d.row<h.row?e:l;var n=d.row<h.row?l:e;a=d.column<h.column?e:l;e=d.column<h.column?l:e;c=this._getPosition(c.get(0)).top;
|
|
35
|
-
a=this._getPosition(a.get(0)).left;d=this._getPosition(n.get(0)).top+n.outerHeight()-c;e=this._getPosition(e.get(0)).left+e.outerWidth()-a;h=this.dom.select;h.top.css({top:c,left:a,width:e});h.left.css({top:c,left:a,height:d});h.bottom.css({top:c+d,left:a,width:e});h.right.css({top:c,left:a+e,height:d})}},_editor:function(a){var d=this.s.dt,c=this.c.editor;if(c){for(var e={},h=[],l=c.fields(),n=0,p=a.length;n<p;n++)for(var r=0,t=a[n].length;r<t;r++){var x=a[n][r],w=d.settings()[0].aoColumns[x.index.column],
|
|
36
|
-
u=w.editField;if(u===k){w=w.mData;for(var y=0,z=l.length;y<z;y++){var A=c.field(l[y]);if(A.dataSrc()===w){u=A.name();break}}}if(!u)throw"Could not automatically determine field data. Please see https://datatables.net/tn/11";e[u]||(e[u]={});w=d.row(x.index.row).id();e[u][w]=x.set;h.push(x.index)}c.bubble(h,!1).multiSet(e).submit()}},_emitEvent:function(a,d){this.s.dt.iterator("table",function(c,e){b(c.nTable).triggerHandler(a+".dt",d)})},_focusListener:function(){var a=this,d=this.s.dt,c=this.s.namespace,
|
|
37
|
-
e=null!==this.c.focus?this.c.focus:d.init().keys||d.settings()[0].keytable?"focus":"hover";if("focus"===e)d.on("key-focus.autoFill",function(h,l,n){a._attach(n.node())}).on("key-blur.autoFill",function(h,l,n){a._detach()});else if("click"===e)b(d.table().body()).on("click"+c,"td, th",function(h){a._attach(this)}),b(g.body).on("click"+c,function(h){b(h.target).parents().filter(d.table().body()).length||a._detach()});else b(d.table().body()).on("mouseenter"+c+" touchstart"+c,"td, th",function(h){a._attach(this)}).on("mouseleave"+
|
|
38
|
-
c+"touchend"+c,function(h){b(h.relatedTarget).hasClass("dt-autofill-handle")||a._detach()})},_focusListenerRemove:function(){var a=this.s.dt;a.off(".autoFill");b(a.table().body()).off(this.s.namespace);b(g.body).off(this.s.namespace)},_getPosition:function(a,d){var c=0,e=0;d||(d=b(b(this.s.dt.table().node())[0].offsetParent));do{var h=a.offsetTop,l=a.offsetLeft;var n=b(a.offsetParent);c+=h+1*parseInt(n.css("border-top-width")||0);e+=l+1*parseInt(n.css("border-left-width")||0);if("body"===a.nodeName.toLowerCase())break;
|
|
39
|
-
a=n.get(0)}while(n.get(0)!==d.get(0));return{top:c,left:e}},_mousedown:function(a){var d=this,c=this.s.dt;this.dom.start=this.dom.attachedTo;this.s.start={row:c.rows({page:"current"}).nodes().indexOf(b(this.dom.start).parent()[0]),column:b(this.dom.start).index()};b(g.body).on("mousemove.autoFill touchmove.autoFill",function(h){d._mousemove(h);if("touchmove"===h.type)b(g.body).one("touchend.autoFill",function(){d._detach()})}).on("mouseup.autoFill touchend.autoFill",function(h){d._mouseup(h)});var e=
|
|
40
|
-
this.dom.select;c=b(c.table().node()).offsetParent();e.top.appendTo(c);e.left.appendTo(c);e.right.appendTo(c);e.bottom.appendTo(c);this._drawSelection(this.dom.start,a);this.dom.handle.css("display","none");a=this.dom.dtScroll;this.s.scroll={windowHeight:b(f).height(),windowWidth:b(f).width(),dtTop:a?a.offset().top:null,dtLeft:a?a.offset().left:null,dtHeight:a?a.outerHeight():null,dtWidth:a?a.outerWidth():null}},_mousemove:function(a){var d=a.type.includes("touch")?g.elementFromPoint(a.touches[0].clientX,
|
|
41
|
-
a.touches[0].clientY):a.target,c=d.nodeName.toLowerCase();if("td"===c||"th"===c)this._drawSelection(d,a),this._shiftScroll(a)},_mouseup:function(a){b(g.body).off(".autoFill");var d=this,c=this.s.dt,e=this.dom.select;e.top.remove();e.left.remove();e.right.remove();e.bottom.remove();this.dom.handle.css("display","block");e=this.s.start;var h=this.s.end;if(e.row!==h.row||e.column!==h.column){var l=c.cell(":eq("+e.row+")",e.column+":visible",{page:"current"});if(b("div.DTE",l.node()).length){var n=c.editor();
|
|
42
|
-
n.on("submitSuccess.dtaf close.dtaf",function(){n.off(".dtaf");setTimeout(function(){d._mouseup(a)},100)}).on("submitComplete.dtaf preSubmitCancelled.dtaf close.dtaf",function(){n.off(".dtaf")});n.submit()}else{var p=this._range(e.row,h.row);e=this._range(e.column,h.column);h=[];for(var r=c.settings()[0],t=r.aoColumns,x=c.columns(this.c.columns).indexes(),w=0;w<p.length;w++)h.push(b.map(e,function(u){var y=c.row(":eq("+p[w]+")",{page:"current"});u=c.cell(y.index(),u+":visible");y=u.data();var z=u.index(),
|
|
43
|
-
A=t[z.column].editField;A!==k&&(y=r.oApi._fnGetObjectDataFn(A)(c.row(z.row).data()));if(-1!==x.indexOf(z.column))return{cell:u,data:y,label:u.data(),index:z}}));this._actionSelector(h);clearInterval(this.s.scrollInterval);this.s.scrollInterval=null}}},_range:function(a,d){var c=[];if(a<=d)for(;a<=d;a++)c.push(a);else for(;a>=d;a--)c.push(a);return c},_shiftScroll:function(a){var d=this,c=this.s.scroll,e=!1,h=a.type.includes("touch")?a.touches[0].clientX:a.pageX-f.scrollX;a=a.type.includes("touch")?
|
|
44
|
-
a.touches[0].clientY:a.pageY-f.scrollY;var l,n,p,r;65>a?l=-5:a>c.windowHeight-65&&(l=5);65>h?n=-5:h>c.windowWidth-65&&(n=5);null!==c.dtTop&&a<c.dtTop+65?p=-5:null!==c.dtTop&&a>c.dtTop+c.dtHeight-65&&(p=5);null!==c.dtLeft&&h<c.dtLeft+65?r=-5:null!==c.dtLeft&&h>c.dtLeft+c.dtWidth-65&&(r=5);l||n||p||r?(c.windowVert=l,c.windowHoriz=n,c.dtVert=p,c.dtHoriz=r,e=!0):this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null);!this.s.scrollInterval&&e&&(this.s.scrollInterval=setInterval(function(){f.scrollTo(f.scrollX+
|
|
45
|
-
(c.windowHoriz?c.windowHoriz:0),f.scrollY+(c.windowVert?c.windowVert:0));if(c.dtVert||c.dtHoriz){var t=d.dom.dtScroll[0];c.dtVert&&(t.scrollTop+=c.dtVert);c.dtHoriz&&(t.scrollLeft+=c.dtHoriz)}},20))},_update:function(a,d){if(!1!==a){a=this.s.dt;var c=a.columns(this.c.columns).indexes();this._emitEvent("preAutoFill",[a,d]);this._editor(d);if(null!==this.c.update?this.c.update:!this.c.editor){for(var e=0,h=d.length;e<h;e++)for(var l=0,n=d[e].length;l<n;l++){var p=d[e][l];-1!==c.indexOf(p.index.column)&&
|
|
46
|
-
p.cell.data(p.set)}a.draw(!1)}this._emitEvent("autoFill",[a,d])}}});q.actions={increment:{available:function(a,d){a=d[0][0].label;return!isNaN(a-parseFloat(a))},option:function(a,d){return a.i18n("autoFill.increment",'Increment / decrement each cell by: <input type="number" value="1">')},execute:function(a,d,c){a=1*d[0][0].data;c=1*b("input",c).val();for(var e=0,h=d.length;e<h;e++)for(var l=0,n=d[e].length;l<n;l++)d[e][l].set=a,a+=c}},fill:{available:function(a,d){return!0},option:function(a,d){return a.i18n("autoFill.fill",
|
|
47
|
-
"Fill all cells with <i>%d</i>",d[0][0].label)},execute:function(a,d,c){a=d[0][0].data;c=0;for(var e=d.length;c<e;c++)for(var h=0,l=d[c].length;h<l;h++)d[c][h].set=a}},fillHorizontal:{available:function(a,d){return 1<d.length&&1<d[0].length},option:function(a,d){return a.i18n("autoFill.fillHorizontal","Fill cells horizontally")},execute:function(a,d,c){a=0;for(c=d.length;a<c;a++)for(var e=0,h=d[a].length;e<h;e++)d[a][e].set=d[a][0].data}},fillVertical:{available:function(a,d){return 1<d.length},option:function(a,
|
|
48
|
-
d){return a.i18n("autoFill.fillVertical","Fill cells vertically")},execute:function(a,d,c){a=0;for(c=d.length;a<c;a++)for(var e=0,h=d[a].length;e<h;e++)d[a][e].set=d[0][e].data}},cancel:{available:function(){return!1},option:function(a){return a.i18n("autoFill.cancel","Cancel")},execute:function(){return!1}}};q.version="2.3.9";q.defaults={alwaysAsk:!1,focus:null,columns:"",enable:!0,update:null,editor:null,vertical:!0,horizontal:!0};q.classes={btn:"btn"};var B=b.fn.dataTable.Api;B.register("autoFill()",
|
|
49
|
-
function(){return this});B.register("autoFill().enabled()",function(){var a=this.context[0];return a.autoFill?a.autoFill.enabled():!1});B.register("autoFill().enable()",function(a){return this.iterator("table",function(d){d.autoFill&&d.autoFill.enable(a)})});B.register("autoFill().disable()",function(){return this.iterator("table",function(a){a.autoFill&&a.autoFill.disable()})});b(g).on("preInit.dt.autofill",function(a,d,c){"dt"===a.namespace&&(a=d.oInit.autoFill,c=m.defaults.autoFill,a||c)&&(c=b.extend({},
|
|
50
|
-
a,c),!1!==a&&new q(d,c))});m.AutoFill=q;return m.AutoFill=q});
|
|
1
|
+
/*! AutoFill 2.5.0
|
|
2
|
+
* ©2008-2022 SpryMedia Ltd - datatables.net/license
|
|
3
|
+
*/
|
|
4
|
+
!function(o){"function"==typeof define&&define.amd?define(["jquery","datatables.net"],function(t){return o(t,window,document)}):"object"==typeof exports?module.exports=function(t,e){return t=t||window,(e=e||("undefined"!=typeof window?require("jquery"):require("jquery")(t))).fn.dataTable||require("datatables.net")(t,e),o(e,t,t.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){this.s.dt;var e=t.type.includes("touch")?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.0",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,n.AutoFill=r,n});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! AutoFill 2.5.0
|
|
2
|
+
* ©2008-2022 SpryMedia Ltd - datatables.net/license
|
|
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){this.s.dt;var e=t.type.includes("touch")?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.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;"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,DataTable.AutoFill=AutoFill;export default DataTable;
|