datatables.net-autofill 2.3.9 → 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 +121 -60
- package/js/dataTables.autoFill.min.js +4 -46
- package/js/dataTables.autoFill.min.mjs +4 -0
- package/js/dataTables.autoFill.mjs +1237 -0
- package/package.json +6 -3
- package/types/types.d.ts +182 -0
|
@@ -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
|
|
|
@@ -163,11 +175,40 @@ $.extend( AutoFill.prototype, {
|
|
|
163
175
|
|
|
164
176
|
this._focusListener();
|
|
165
177
|
|
|
166
|
-
this.dom.handle.on( 'mousedown', function (e) {
|
|
178
|
+
this.dom.handle.on( 'mousedown touchstart', function (e) {
|
|
167
179
|
that._mousedown( e );
|
|
168
180
|
return false;
|
|
169
181
|
} );
|
|
170
182
|
|
|
183
|
+
$(window).on('resize', function() {
|
|
184
|
+
var handle = $('div.dt-autofill-handle');
|
|
185
|
+
if(handle.length > 0 && that.dom.attachedTo !== undefined) {
|
|
186
|
+
that._attach(that.dom.attachedTo)
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
let orientationReset = function() {
|
|
191
|
+
that.s.handle = {
|
|
192
|
+
height: false,
|
|
193
|
+
width: false
|
|
194
|
+
};
|
|
195
|
+
$(that.dom.handle).css({
|
|
196
|
+
'height': '',
|
|
197
|
+
'width': ''
|
|
198
|
+
})
|
|
199
|
+
if(that.dom.attachedTo !== undefined) {
|
|
200
|
+
that._attach(that.dom.attachedTo)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
$(window)
|
|
205
|
+
.on('orientationchange', function() {
|
|
206
|
+
setTimeout(function() {
|
|
207
|
+
orientationReset();
|
|
208
|
+
setTimeout(orientationReset, 150);
|
|
209
|
+
}, 50);
|
|
210
|
+
});
|
|
211
|
+
|
|
171
212
|
return this;
|
|
172
213
|
},
|
|
173
214
|
|
|
@@ -256,7 +297,7 @@ $.extend( AutoFill.prototype, {
|
|
|
256
297
|
|
|
257
298
|
// Might need to go through multiple offset parents
|
|
258
299
|
var offset = this._getPosition( node, this.dom.offsetParent );
|
|
259
|
-
|
|
300
|
+
|
|
260
301
|
this.dom.attachedTo = node;
|
|
261
302
|
handle
|
|
262
303
|
.css( {
|
|
@@ -308,25 +349,33 @@ $.extend( AutoFill.prototype, {
|
|
|
308
349
|
actions[ name ].option( dt, cells )+
|
|
309
350
|
'<div>'
|
|
310
351
|
)
|
|
311
|
-
.append( $('<div class="dt-autofill-button">' )
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
} )
|
|
322
|
-
)
|
|
323
|
-
)
|
|
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
|
+
} )
|
|
324
362
|
);
|
|
325
363
|
} );
|
|
326
364
|
|
|
327
365
|
this.dom.background.appendTo( 'body' );
|
|
366
|
+
this.dom.background.one('click', function() {
|
|
367
|
+
that.dom.background.remove();
|
|
368
|
+
that.dom.list.remove();
|
|
369
|
+
})
|
|
328
370
|
this.dom.list.appendTo( 'body' );
|
|
329
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
|
+
|
|
330
379
|
this.dom.list.css( 'margin-top', this.dom.list.outerHeight()/2 * -1 );
|
|
331
380
|
}
|
|
332
381
|
},
|
|
@@ -376,7 +425,7 @@ $.extend( AutoFill.prototype, {
|
|
|
376
425
|
}
|
|
377
426
|
|
|
378
427
|
// if target is not in the columns available - do nothing
|
|
379
|
-
if ( dt.columns( this.c.columns ).indexes().indexOf( colIndx ) === -1 ) {
|
|
428
|
+
if ( dt.columns( this.c.columns ).indexes().indexOf( colIndx ) === -1 || end.row === -1) {
|
|
380
429
|
return;
|
|
381
430
|
}
|
|
382
431
|
|
|
@@ -550,16 +599,18 @@ $.extend( AutoFill.prototype, {
|
|
|
550
599
|
}
|
|
551
600
|
else {
|
|
552
601
|
$(dt.table().body())
|
|
553
|
-
.on( 'mouseenter'+namespace, 'td, th', function (e) {
|
|
602
|
+
.on( 'mouseenter'+namespace+' touchstart'+namespace, 'td, th', function (e) {
|
|
554
603
|
that._attach( this );
|
|
555
604
|
} )
|
|
556
|
-
.on( 'mouseleave'+namespace, function (e) {
|
|
605
|
+
.on( 'mouseleave'+namespace+'touchend'+namespace, function (e) {
|
|
557
606
|
if ( $(e.relatedTarget).hasClass('dt-autofill-handle') ) {
|
|
558
607
|
return;
|
|
559
608
|
}
|
|
560
609
|
|
|
561
610
|
that._detach();
|
|
562
611
|
} );
|
|
612
|
+
|
|
613
|
+
|
|
563
614
|
}
|
|
564
615
|
},
|
|
565
616
|
|
|
@@ -640,10 +691,16 @@ $.extend( AutoFill.prototype, {
|
|
|
640
691
|
};
|
|
641
692
|
|
|
642
693
|
$(document.body)
|
|
643
|
-
.on( 'mousemove.autoFill', function (e) {
|
|
694
|
+
.on( 'mousemove.autoFill touchmove.autoFill', function (e) {
|
|
644
695
|
that._mousemove( e );
|
|
696
|
+
// If it is a touch event then when the touch ends we need to remove the handle
|
|
697
|
+
if(e.type === 'touchmove') {
|
|
698
|
+
$(document.body).one('touchend.autoFill', function() {
|
|
699
|
+
that._detach();
|
|
700
|
+
})
|
|
701
|
+
}
|
|
645
702
|
} )
|
|
646
|
-
.on( 'mouseup.autoFill', function (e) {
|
|
703
|
+
.on( 'mouseup.autoFill touchend.autoFill', function (e) {
|
|
647
704
|
that._mouseup( e );
|
|
648
705
|
} );
|
|
649
706
|
|
|
@@ -684,12 +741,13 @@ $.extend( AutoFill.prototype, {
|
|
|
684
741
|
{
|
|
685
742
|
var that = this;
|
|
686
743
|
var dt = this.s.dt;
|
|
687
|
-
var
|
|
744
|
+
var target = !e.type.includes('touch') ? e.target : document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY);
|
|
745
|
+
var name = target.nodeName.toLowerCase();
|
|
688
746
|
if ( name !== 'td' && name !== 'th' ) {
|
|
689
747
|
return;
|
|
690
748
|
}
|
|
691
749
|
|
|
692
|
-
this._drawSelection(
|
|
750
|
+
this._drawSelection( target, e );
|
|
693
751
|
this._shiftScroll( e );
|
|
694
752
|
},
|
|
695
753
|
|
|
@@ -841,9 +899,13 @@ $.extend( AutoFill.prototype, {
|
|
|
841
899
|
var runInterval = false;
|
|
842
900
|
var scrollSpeed = 5;
|
|
843
901
|
var buffer = 65;
|
|
902
|
+
|
|
903
|
+
// Different values if using a touchscreen
|
|
904
|
+
var pageX = !e.type.includes('touch') ? e.pageX - window.scrollX :e.touches[0].clientX;
|
|
905
|
+
var pageY = !e.type.includes('touch') ? e.pageY - window.scrollY :e.touches[0].clientY;
|
|
844
906
|
var
|
|
845
|
-
windowY =
|
|
846
|
-
windowX =
|
|
907
|
+
windowY = pageY,
|
|
908
|
+
windowX = pageX,
|
|
847
909
|
windowVert, windowHoriz,
|
|
848
910
|
dtVert, dtHoriz;
|
|
849
911
|
|
|
@@ -865,17 +927,17 @@ $.extend( AutoFill.prototype, {
|
|
|
865
927
|
|
|
866
928
|
// DataTables scrolling calculations - based on the table's position in
|
|
867
929
|
// the document and the mouse position on the page
|
|
868
|
-
if ( scroll.dtTop !== null &&
|
|
930
|
+
if ( scroll.dtTop !== null && pageY < scroll.dtTop + buffer ) {
|
|
869
931
|
dtVert = scrollSpeed * -1;
|
|
870
932
|
}
|
|
871
|
-
else if ( scroll.dtTop !== null &&
|
|
933
|
+
else if ( scroll.dtTop !== null && pageY > scroll.dtTop + scroll.dtHeight - buffer ) {
|
|
872
934
|
dtVert = scrollSpeed;
|
|
873
935
|
}
|
|
874
936
|
|
|
875
|
-
if ( scroll.dtLeft !== null &&
|
|
937
|
+
if ( scroll.dtLeft !== null && pageX < scroll.dtLeft + buffer ) {
|
|
876
938
|
dtHoriz = scrollSpeed * -1;
|
|
877
939
|
}
|
|
878
|
-
else if ( scroll.dtLeft !== null &&
|
|
940
|
+
else if ( scroll.dtLeft !== null && pageX > scroll.dtLeft + scroll.dtWidth - buffer ) {
|
|
879
941
|
dtHoriz = scrollSpeed;
|
|
880
942
|
}
|
|
881
943
|
|
|
@@ -906,12 +968,7 @@ $.extend( AutoFill.prototype, {
|
|
|
906
968
|
this.s.scrollInterval = setInterval( function () {
|
|
907
969
|
// Don't need to worry about setting scroll <0 or beyond the
|
|
908
970
|
// scroll bound as the browser will just reject that.
|
|
909
|
-
|
|
910
|
-
document.body.scrollTop += scroll.windowVert;
|
|
911
|
-
}
|
|
912
|
-
if ( scroll.windowHoriz ) {
|
|
913
|
-
document.body.scrollLeft += scroll.windowHoriz;
|
|
914
|
-
}
|
|
971
|
+
window.scrollTo(window.scrollX + (scroll.windowHoriz ? scroll.windowHoriz : 0), window.scrollY + (scroll.windowVert ? scroll.windowVert : 0))
|
|
915
972
|
|
|
916
973
|
// DataTables scrolling
|
|
917
974
|
if ( scroll.dtVert || scroll.dtHoriz ) {
|
|
@@ -1061,7 +1118,7 @@ AutoFill.actions = {
|
|
|
1061
1118
|
|
|
1062
1119
|
fillVertical: {
|
|
1063
1120
|
available: function ( dt, cells ) {
|
|
1064
|
-
return cells.length > 1;
|
|
1121
|
+
return cells.length > 1 && cells[0].length > 1;
|
|
1065
1122
|
},
|
|
1066
1123
|
|
|
1067
1124
|
option: function ( dt, cells ) {
|
|
@@ -1102,7 +1159,7 @@ AutoFill.actions = {
|
|
|
1102
1159
|
* @static
|
|
1103
1160
|
* @type String
|
|
1104
1161
|
*/
|
|
1105
|
-
AutoFill.version = '2.
|
|
1162
|
+
AutoFill.version = '2.5.0';
|
|
1106
1163
|
|
|
1107
1164
|
|
|
1108
1165
|
/**
|
|
@@ -1114,6 +1171,8 @@ AutoFill.defaults = {
|
|
|
1114
1171
|
/** @type {Boolean} Ask user what they want to do, even for a single option */
|
|
1115
1172
|
alwaysAsk: false,
|
|
1116
1173
|
|
|
1174
|
+
closeButton: true,
|
|
1175
|
+
|
|
1117
1176
|
/** @type {string|null} What will trigger a focus */
|
|
1118
1177
|
focus: null, // focus, click, hover
|
|
1119
1178
|
|
|
@@ -1144,7 +1203,9 @@ AutoFill.defaults = {
|
|
|
1144
1203
|
*/
|
|
1145
1204
|
AutoFill.classes = {
|
|
1146
1205
|
/** @type {String} Class used by the selection button */
|
|
1147
|
-
btn: 'btn'
|
|
1206
|
+
btn: 'btn',
|
|
1207
|
+
|
|
1208
|
+
closeable: 'dtaf-popover-closeable'
|
|
1148
1209
|
};
|
|
1149
1210
|
|
|
1150
1211
|
|
|
@@ -1208,5 +1269,5 @@ DataTable.AutoFill = AutoFill;
|
|
|
1208
1269
|
DataTable.AutoFill = AutoFill;
|
|
1209
1270
|
|
|
1210
1271
|
|
|
1211
|
-
return
|
|
1272
|
+
return DataTable;
|
|
1212
1273
|
}));
|
|
@@ -1,46 +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(c){var h=0;return function(){return h<c.length?{done:!1,value:c[h++]}:{done:!0}}};$jscomp.arrayIterator=function(c){return{next:$jscomp.arrayIteratorImpl(c)}};$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(c,h,g){if(c==Array.prototype||c==Object.prototype)return c;c[h]=g.value;return c};$jscomp.getGlobal=function(c){c=["object"==typeof globalThis&&globalThis,c,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var h=0;h<c.length;++h){var g=c[h];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(c,h){var g=$jscomp.propertyToPolyfillSymbol[h];if(null==g)return c[h];g=c[g];return void 0!==g?g:c[h]};
|
|
18
|
-
$jscomp.polyfill=function(c,h,g,k){h&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(c,h,g,k):$jscomp.polyfillUnisolated(c,h,g,k))};$jscomp.polyfillUnisolated=function(c,h,g,k){g=$jscomp.global;c=c.split(".");for(k=0;k<c.length-1;k++){var l=c[k];if(!(l in g))return;g=g[l]}c=c[c.length-1];k=g[c];h=h(k);h!=k&&null!=h&&$jscomp.defineProperty(g,c,{configurable:!0,writable:!0,value:h})};
|
|
19
|
-
$jscomp.polyfillIsolated=function(c,h,g,k){var l=c.split(".");c=1===l.length;k=l[0];k=!c&&k in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var y=0;y<l.length-1;y++){var r=l[y];if(!(r in k))return;k=k[r]}l=l[l.length-1];g=$jscomp.IS_SYMBOL_NATIVE&&"es6"===g?k[l]:null;h=h(g);null!=h&&(c?$jscomp.defineProperty($jscomp.polyfills,l,{configurable:!0,writable:!0,value:h}):h!==g&&($jscomp.propertyToPolyfillSymbol[l]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(l):$jscomp.POLYFILL_PREFIX+l,l=
|
|
20
|
-
$jscomp.propertyToPolyfillSymbol[l],$jscomp.defineProperty(k,l,{configurable:!0,writable:!0,value:h})))};$jscomp.initSymbol=function(){};
|
|
21
|
-
$jscomp.polyfill("Symbol",function(c){if(c)return c;var h=function(l,y){this.$jscomp$symbol$id_=l;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:y})};h.prototype.toString=function(){return this.$jscomp$symbol$id_};var g=0,k=function(l){if(this instanceof k)throw new TypeError("Symbol is not a constructor");return new h("jscomp_symbol_"+(l||"")+"_"+g++,l)};return k},"es6","es3");$jscomp.initSymbolIterator=function(){};
|
|
22
|
-
$jscomp.polyfill("Symbol.iterator",function(c){if(c)return c;c=Symbol("Symbol.iterator");for(var h="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),g=0;g<h.length;g++){var k=$jscomp.global[h[g]];"function"===typeof k&&"function"!=typeof k.prototype[c]&&$jscomp.defineProperty(k.prototype,c,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}})}return c},"es6",
|
|
23
|
-
"es3");$jscomp.initSymbolAsyncIterator=function(){};$jscomp.iteratorPrototype=function(c){c={next:c};c[Symbol.iterator]=function(){return this};return c};$jscomp.iteratorFromArray=function(c,h){c instanceof String&&(c+="");var g=0,k={next:function(){if(g<c.length){var l=g++;return{value:h(l,c[l]),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(c){return c?c:function(){return $jscomp.iteratorFromArray(this,function(h){return h})}},"es6","es3");
|
|
25
|
-
(function(c){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(h){return c(h,window,document)}):"object"===typeof exports?module.exports=function(h,g){h||(h=window);g&&g.fn.dataTable||(g=require("datatables.net")(h,g).$);return c(g,h,h.document)}:c(jQuery,window,document)})(function(c,h,g,k){var l=c.fn.dataTable,y=0,r=function(a,d){if(!l.versionCheck||!l.versionCheck("1.10.8"))throw"Warning: AutoFill requires DataTables 1.10.8 or greater";this.c=c.extend(!0,{},l.defaults.autoFill,
|
|
26
|
-
r.defaults,d);this.s={dt:new l.Api(a),namespace:".autoFill"+y++,scroll:{},scrollInterval:null,handle:{height:0,width:0},enabled:!1};this.dom={handle:c('<div class="dt-autofill-handle"/>'),select:{top:c('<div class="dt-autofill-select top"/>'),right:c('<div class="dt-autofill-select right"/>'),bottom:c('<div class="dt-autofill-select bottom"/>'),left:c('<div class="dt-autofill-select left"/>')},background:c('<div class="dt-autofill-background"/>'),list:c('<div class="dt-autofill-list">'+this.s.dt.i18n("autoFill.info",
|
|
27
|
-
"")+"<ul/></div>"),dtScroll:null,offsetParent:null};this._constructor()};c.extend(r.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",function(b){d._mousedown(b);return!1});return this},disable:function(){this.s.enabled=!1;this._focusListenerRemove();return this},_constructor:function(){var a=this,d=this.s.dt,b=c("div.dataTables_scrollBody",this.s.dt.table().container());
|
|
28
|
-
d.settings()[0].autoFill=this;b.length&&(this.dom.dtScroll=b,"static"===b.css("position")&&b.css("position","relative"));!1!==this.c.enable&&this.enable();d.on("destroy.autoFill",function(){a._focusListenerRemove()})},_attach:function(a){var d=this.s.dt,b=d.cell(a).index(),e=this.dom.handle,f=this.s.handle;b&&-1!==d.columns(this.c.columns).indexes().indexOf(b.column)?(this.dom.offsetParent||(this.dom.offsetParent=c(d.table().node()).offsetParent()),f.height&&f.width||(e.appendTo("body"),f.height=
|
|
29
|
-
e.outerHeight(),f.width=e.outerWidth()),d=this._getPosition(a,this.dom.offsetParent),this.dom.attachedTo=a,e.css({top:d.top+a.offsetHeight-f.height,left:d.left+a.offsetWidth-f.width}).appendTo(this.dom.offsetParent)):this._detach()},_actionSelector:function(a){var d=this,b=this.s.dt,e=r.actions,f=[];c.each(e,function(p,q){q.available(b,a)&&f.push(p)});if(1===f.length&&!1===this.c.alwaysAsk){var m=e[f[0]].execute(b,a);this._update(m,a)}else if(1<f.length){var n=this.dom.list.children("ul").empty();
|
|
30
|
-
f.push("cancel");c.each(f,function(p,q){n.append(c("<li/>").append('<div class="dt-autofill-question">'+e[q].option(b,a)+"<div>").append(c('<div class="dt-autofill-button">').append(c('<button class="'+r.classes.btn+'">'+b.i18n("autoFill.button",">")+"</button>").on("click",function(){var v=e[q].execute(b,a,c(this).closest("li"));d._update(v,a);d.dom.background.remove();d.dom.list.remove()}))))});this.dom.background.appendTo("body");this.dom.list.appendTo("body");this.dom.list.css("margin-top",
|
|
31
|
-
this.dom.list.outerHeight()/2*-1)}},_detach:function(){this.dom.attachedTo=null;this.dom.handle.detach()},_drawSelection:function(a,d){var b=this.s.dt;d=this.s.start;var e=c(this.dom.start),f={row:this.c.vertical?b.rows({page:"current"}).nodes().indexOf(a.parentNode):d.row,column:this.c.horizontal?c(a).index():d.column};a=b.column.index("toData",f.column);var m=b.row(":eq("+f.row+")",{page:"current"});m=c(b.cell(m.index(),a).node());if(b.cell(m).any()&&-1!==b.columns(this.c.columns).indexes().indexOf(a)){this.s.end=
|
|
32
|
-
f;b=d.row<f.row?e:m;var n=d.row<f.row?m:e;a=d.column<f.column?e:m;e=d.column<f.column?m:e;b=this._getPosition(b.get(0)).top;a=this._getPosition(a.get(0)).left;d=this._getPosition(n.get(0)).top+n.outerHeight()-b;e=this._getPosition(e.get(0)).left+e.outerWidth()-a;f=this.dom.select;f.top.css({top:b,left:a,width:e});f.left.css({top:b,left:a,height:d});f.bottom.css({top:b+d,left:a,width:e});f.right.css({top:b,left:a+e,height:d})}},_editor:function(a){var d=this.s.dt,b=this.c.editor;if(b){for(var e={},
|
|
33
|
-
f=[],m=b.fields(),n=0,p=a.length;n<p;n++)for(var q=0,v=a[n].length;q<v;q++){var u=a[n][q],w=d.settings()[0].aoColumns[u.index.column],t=w.editField;if(t===k){w=w.mData;for(var x=0,z=m.length;x<z;x++){var A=b.field(m[x]);if(A.dataSrc()===w){t=A.name();break}}}if(!t)throw"Could not automatically determine field data. Please see https://datatables.net/tn/11";e[t]||(e[t]={});w=d.row(u.index.row).id();e[t][w]=u.set;f.push(u.index)}b.bubble(f,!1).multiSet(e).submit()}},_emitEvent:function(a,d){this.s.dt.iterator("table",
|
|
34
|
-
function(b,e){c(b.nTable).triggerHandler(a+".dt",d)})},_focusListener:function(){var a=this,d=this.s.dt,b=this.s.namespace,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(f,m,n){a._attach(n.node())}).on("key-blur.autoFill",function(f,m,n){a._detach()});else if("click"===e)c(d.table().body()).on("click"+b,"td, th",function(f){a._attach(this)}),c(g.body).on("click"+b,function(f){c(f.target).parents().filter(d.table().body()).length||
|
|
35
|
-
a._detach()});else c(d.table().body()).on("mouseenter"+b,"td, th",function(f){a._attach(this)}).on("mouseleave"+b,function(f){c(f.relatedTarget).hasClass("dt-autofill-handle")||a._detach()})},_focusListenerRemove:function(){var a=this.s.dt;a.off(".autoFill");c(a.table().body()).off(this.s.namespace);c(g.body).off(this.s.namespace)},_getPosition:function(a,d){var b=0,e=0;d||(d=c(c(this.s.dt.table().node())[0].offsetParent));do{var f=a.offsetTop,m=a.offsetLeft;var n=c(a.offsetParent);b+=f+1*parseInt(n.css("border-top-width")||
|
|
36
|
-
0);e+=m+1*parseInt(n.css("border-left-width")||0);if("body"===a.nodeName.toLowerCase())break;a=n.get(0)}while(n.get(0)!==d.get(0));return{top:b,left:e}},_mousedown:function(a){var d=this,b=this.s.dt;this.dom.start=this.dom.attachedTo;this.s.start={row:b.rows({page:"current"}).nodes().indexOf(c(this.dom.start).parent()[0]),column:c(this.dom.start).index()};c(g.body).on("mousemove.autoFill",function(f){d._mousemove(f)}).on("mouseup.autoFill",function(f){d._mouseup(f)});var e=this.dom.select;b=c(b.table().node()).offsetParent();
|
|
37
|
-
e.top.appendTo(b);e.left.appendTo(b);e.right.appendTo(b);e.bottom.appendTo(b);this._drawSelection(this.dom.start,a);this.dom.handle.css("display","none");a=this.dom.dtScroll;this.s.scroll={windowHeight:c(h).height(),windowWidth:c(h).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.target.nodeName.toLowerCase();if("td"===d||"th"===d)this._drawSelection(a.target,a),this._shiftScroll(a)},_mouseup:function(a){c(g.body).off(".autoFill");
|
|
38
|
-
var d=this,b=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 f=this.s.end;if(e.row!==f.row||e.column!==f.column){var m=b.cell(":eq("+e.row+")",e.column+":visible",{page:"current"});if(c("div.DTE",m.node()).length){var n=b.editor();n.on("submitSuccess.dtaf close.dtaf",function(){n.off(".dtaf");setTimeout(function(){d._mouseup(a)},100)}).on("submitComplete.dtaf preSubmitCancelled.dtaf close.dtaf",
|
|
39
|
-
function(){n.off(".dtaf")});n.submit()}else{var p=this._range(e.row,f.row);e=this._range(e.column,f.column);f=[];for(var q=b.settings()[0],v=q.aoColumns,u=b.columns(this.c.columns).indexes(),w=0;w<p.length;w++)f.push(c.map(e,function(t){var x=b.row(":eq("+p[w]+")",{page:"current"});t=b.cell(x.index(),t+":visible");x=t.data();var z=t.index(),A=v[z.column].editField;A!==k&&(x=q.oApi._fnGetObjectDataFn(A)(b.row(z.row).data()));if(-1!==u.indexOf(z.column))return{cell:t,data:x,label:t.data(),index:z}}));
|
|
40
|
-
this._actionSelector(f);clearInterval(this.s.scrollInterval);this.s.scrollInterval=null}}},_range:function(a,d){var b=[];if(a<=d)for(;a<=d;a++)b.push(a);else for(;a>=d;a--)b.push(a);return b},_shiftScroll:function(a){var d=this,b=this.s.scroll,e=!1,f=a.pageY-g.body.scrollTop,m=a.pageX-g.body.scrollLeft,n,p,q,v;65>f?n=-5:f>b.windowHeight-65&&(n=5);65>m?p=-5:m>b.windowWidth-65&&(p=5);null!==b.dtTop&&a.pageY<b.dtTop+65?q=-5:null!==b.dtTop&&a.pageY>b.dtTop+b.dtHeight-65&&(q=5);null!==b.dtLeft&&a.pageX<
|
|
41
|
-
b.dtLeft+65?v=-5:null!==b.dtLeft&&a.pageX>b.dtLeft+b.dtWidth-65&&(v=5);n||p||q||v?(b.windowVert=n,b.windowHoriz=p,b.dtVert=q,b.dtHoriz=v,e=!0):this.s.scrollInterval&&(clearInterval(this.s.scrollInterval),this.s.scrollInterval=null);!this.s.scrollInterval&&e&&(this.s.scrollInterval=setInterval(function(){b.windowVert&&(g.body.scrollTop+=b.windowVert);b.windowHoriz&&(g.body.scrollLeft+=b.windowHoriz);if(b.dtVert||b.dtHoriz){var u=d.dom.dtScroll[0];b.dtVert&&(u.scrollTop+=b.dtVert);b.dtHoriz&&(u.scrollLeft+=
|
|
42
|
-
b.dtHoriz)}},20))},_update:function(a,d){if(!1!==a){a=this.s.dt;var b=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,f=d.length;e<f;e++)for(var m=0,n=d[e].length;m<n;m++){var p=d[e][m];-1!==b.indexOf(p.index.column)&&p.cell.data(p.set)}a.draw(!1)}this._emitEvent("autoFill",[a,d])}}});r.actions={increment:{available:function(a,d){a=d[0][0].label;return!isNaN(a-parseFloat(a))},option:function(a,
|
|
43
|
-
d){return a.i18n("autoFill.increment",'Increment / decrement each cell by: <input type="number" value="1">')},execute:function(a,d,b){a=1*d[0][0].data;b=1*c("input",b).val();for(var e=0,f=d.length;e<f;e++)for(var m=0,n=d[e].length;m<n;m++)d[e][m].set=a,a+=b}},fill:{available:function(a,d){return!0},option:function(a,d){return a.i18n("autoFill.fill","Fill all cells with <i>%d</i>",d[0][0].label)},execute:function(a,d,b){a=d[0][0].data;b=0;for(var e=d.length;b<e;b++)for(var f=0,m=d[b].length;f<m;f++)d[b][f].set=
|
|
44
|
-
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,b){a=0;for(b=d.length;a<b;a++)for(var e=0,f=d[a].length;e<f;e++)d[a][e].set=d[a][0].data}},fillVertical:{available:function(a,d){return 1<d.length},option:function(a,d){return a.i18n("autoFill.fillVertical","Fill cells vertically")},execute:function(a,d,b){a=0;for(b=d.length;a<b;a++)for(var e=0,f=d[a].length;e<f;e++)d[a][e].set=
|
|
45
|
-
d[0][e].data}},cancel:{available:function(){return!1},option:function(a){return a.i18n("autoFill.cancel","Cancel")},execute:function(){return!1}}};r.version="2.3.9";r.defaults={alwaysAsk:!1,focus:null,columns:"",enable:!0,update:null,editor:null,vertical:!0,horizontal:!0};r.classes={btn:"btn"};var B=c.fn.dataTable.Api;B.register("autoFill()",function(){return this});B.register("autoFill().enabled()",function(){var a=this.context[0];return a.autoFill?a.autoFill.enabled():!1});B.register("autoFill().enable()",
|
|
46
|
-
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()})});c(g).on("preInit.dt.autofill",function(a,d,b){"dt"===a.namespace&&(a=d.oInit.autoFill,b=l.defaults.autoFill,a||b)&&(b=c.extend({},a,b),!1!==a&&new r(d,b))});l.AutoFill=r;return l.AutoFill=r});
|
|
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;
|