datatables.net-autofill 2.3.7 → 2.4.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/Readme.md +1 -1
- package/js/dataTables.autoFill.js +65 -24
- package/js/dataTables.autoFill.min.js +47 -23
- package/package.json +5 -4
- package/types/types.d.ts +66 -0
package/Readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AutoFill for DataTables
|
|
2
2
|
|
|
3
|
-
This package contains distribution files for the [AutoFill extension](https://datatables.net/extensions/
|
|
3
|
+
This package contains distribution files for the [AutoFill extension](https://datatables.net/extensions/autofill) for [DataTables](https://datatables.net/). Only the core software for this library is contained in this package - to be correctly styled, a styling package for AutoFill must also be included. Styling options include DataTable's native styling, [Bootstrap](http://getbootstrap.com) and [Foundation](http://foundation.zurb.com/).
|
|
4
4
|
|
|
5
5
|
AutoFill adds an Excel like data fill option to DataTables, allowing click and drag over cells, filling in information and incrementing numbers as needed.
|
|
6
6
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/*! AutoFill 2.3.
|
|
1
|
+
/*! AutoFill 2.3.9
|
|
2
2
|
* ©2008-2021 SpryMedia Ltd - datatables.net/license
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @summary AutoFill
|
|
7
7
|
* @description Add Excel like click and drag auto-fill options to DataTables
|
|
8
|
-
* @version 2.3.
|
|
8
|
+
* @version 2.3.9
|
|
9
9
|
* @file dataTables.autoFill.js
|
|
10
10
|
* @author SpryMedia Ltd (www.sprymedia.co.uk)
|
|
11
11
|
* @contact www.sprymedia.co.uk/contact
|
|
@@ -163,11 +163,40 @@ $.extend( AutoFill.prototype, {
|
|
|
163
163
|
|
|
164
164
|
this._focusListener();
|
|
165
165
|
|
|
166
|
-
this.dom.handle.on( 'mousedown', function (e) {
|
|
166
|
+
this.dom.handle.on( 'mousedown touchstart', function (e) {
|
|
167
167
|
that._mousedown( e );
|
|
168
168
|
return false;
|
|
169
169
|
} );
|
|
170
170
|
|
|
171
|
+
$(window).on('resize', function() {
|
|
172
|
+
var handle = $('div.dt-autofill-handle');
|
|
173
|
+
if(handle.length > 0 && that.dom.attachedTo !== undefined) {
|
|
174
|
+
that._attach(that.dom.attachedTo)
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
let orientationReset = function() {
|
|
179
|
+
that.s.handle = {
|
|
180
|
+
height: false,
|
|
181
|
+
width: false
|
|
182
|
+
};
|
|
183
|
+
$(that.dom.handle).css({
|
|
184
|
+
'height': '',
|
|
185
|
+
'width': ''
|
|
186
|
+
})
|
|
187
|
+
if(that.dom.attachedTo !== undefined) {
|
|
188
|
+
that._attach(that.dom.attachedTo)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
$(window)
|
|
193
|
+
.on('orientationchange', function() {
|
|
194
|
+
setTimeout(function() {
|
|
195
|
+
orientationReset();
|
|
196
|
+
setTimeout(orientationReset, 150);
|
|
197
|
+
}, 50);
|
|
198
|
+
});
|
|
199
|
+
|
|
171
200
|
return this;
|
|
172
201
|
},
|
|
173
202
|
|
|
@@ -256,7 +285,7 @@ $.extend( AutoFill.prototype, {
|
|
|
256
285
|
|
|
257
286
|
// Might need to go through multiple offset parents
|
|
258
287
|
var offset = this._getPosition( node, this.dom.offsetParent );
|
|
259
|
-
|
|
288
|
+
|
|
260
289
|
this.dom.attachedTo = node;
|
|
261
290
|
handle
|
|
262
291
|
.css( {
|
|
@@ -325,6 +354,10 @@ $.extend( AutoFill.prototype, {
|
|
|
325
354
|
} );
|
|
326
355
|
|
|
327
356
|
this.dom.background.appendTo( 'body' );
|
|
357
|
+
this.dom.background.one('click', () => {
|
|
358
|
+
this.dom.background.remove();
|
|
359
|
+
this.dom.list.remove();
|
|
360
|
+
})
|
|
328
361
|
this.dom.list.appendTo( 'body' );
|
|
329
362
|
|
|
330
363
|
this.dom.list.css( 'margin-top', this.dom.list.outerHeight()/2 * -1 );
|
|
@@ -376,7 +409,7 @@ $.extend( AutoFill.prototype, {
|
|
|
376
409
|
}
|
|
377
410
|
|
|
378
411
|
// if target is not in the columns available - do nothing
|
|
379
|
-
if ( dt.columns( this.c.columns ).indexes().indexOf( colIndx ) === -1 ) {
|
|
412
|
+
if ( dt.columns( this.c.columns ).indexes().indexOf( colIndx ) === -1 || end.row === -1) {
|
|
380
413
|
return;
|
|
381
414
|
}
|
|
382
415
|
|
|
@@ -550,16 +583,18 @@ $.extend( AutoFill.prototype, {
|
|
|
550
583
|
}
|
|
551
584
|
else {
|
|
552
585
|
$(dt.table().body())
|
|
553
|
-
.on( 'mouseenter'+namespace, 'td, th', function (e) {
|
|
586
|
+
.on( 'mouseenter'+namespace+' touchstart'+namespace, 'td, th', function (e) {
|
|
554
587
|
that._attach( this );
|
|
555
588
|
} )
|
|
556
|
-
.on( 'mouseleave'+namespace, function (e) {
|
|
589
|
+
.on( 'mouseleave'+namespace+'touchend'+namespace, function (e) {
|
|
557
590
|
if ( $(e.relatedTarget).hasClass('dt-autofill-handle') ) {
|
|
558
591
|
return;
|
|
559
592
|
}
|
|
560
593
|
|
|
561
594
|
that._detach();
|
|
562
595
|
} );
|
|
596
|
+
|
|
597
|
+
|
|
563
598
|
}
|
|
564
599
|
},
|
|
565
600
|
|
|
@@ -640,10 +675,16 @@ $.extend( AutoFill.prototype, {
|
|
|
640
675
|
};
|
|
641
676
|
|
|
642
677
|
$(document.body)
|
|
643
|
-
.on( 'mousemove.autoFill', function (e) {
|
|
678
|
+
.on( 'mousemove.autoFill touchmove.autoFill', function (e) {
|
|
644
679
|
that._mousemove( e );
|
|
680
|
+
// If it is a touch event then when the touch ends we need to remove the handle
|
|
681
|
+
if(e.type === 'touchmove') {
|
|
682
|
+
$(document.body).one('touchend.autoFill', function() {
|
|
683
|
+
that._detach();
|
|
684
|
+
})
|
|
685
|
+
}
|
|
645
686
|
} )
|
|
646
|
-
.on( 'mouseup.autoFill', function (e) {
|
|
687
|
+
.on( 'mouseup.autoFill touchend.autoFill', function (e) {
|
|
647
688
|
that._mouseup( e );
|
|
648
689
|
} );
|
|
649
690
|
|
|
@@ -684,12 +725,13 @@ $.extend( AutoFill.prototype, {
|
|
|
684
725
|
{
|
|
685
726
|
var that = this;
|
|
686
727
|
var dt = this.s.dt;
|
|
687
|
-
var
|
|
728
|
+
var target = !e.type.includes('touch') ? e.target : document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY);
|
|
729
|
+
var name = target.nodeName.toLowerCase();
|
|
688
730
|
if ( name !== 'td' && name !== 'th' ) {
|
|
689
731
|
return;
|
|
690
732
|
}
|
|
691
733
|
|
|
692
|
-
this._drawSelection(
|
|
734
|
+
this._drawSelection( target, e );
|
|
693
735
|
this._shiftScroll( e );
|
|
694
736
|
},
|
|
695
737
|
|
|
@@ -841,9 +883,13 @@ $.extend( AutoFill.prototype, {
|
|
|
841
883
|
var runInterval = false;
|
|
842
884
|
var scrollSpeed = 5;
|
|
843
885
|
var buffer = 65;
|
|
886
|
+
|
|
887
|
+
// Different values if using a touchscreen
|
|
888
|
+
var pageX = !e.type.includes('touch') ? e.pageX - window.scrollX :e.touches[0].clientX;
|
|
889
|
+
var pageY = !e.type.includes('touch') ? e.pageY - window.scrollY :e.touches[0].clientY;
|
|
844
890
|
var
|
|
845
|
-
windowY =
|
|
846
|
-
windowX =
|
|
891
|
+
windowY = pageY,
|
|
892
|
+
windowX = pageX,
|
|
847
893
|
windowVert, windowHoriz,
|
|
848
894
|
dtVert, dtHoriz;
|
|
849
895
|
|
|
@@ -865,17 +911,17 @@ $.extend( AutoFill.prototype, {
|
|
|
865
911
|
|
|
866
912
|
// DataTables scrolling calculations - based on the table's position in
|
|
867
913
|
// the document and the mouse position on the page
|
|
868
|
-
if ( scroll.dtTop !== null &&
|
|
914
|
+
if ( scroll.dtTop !== null && pageY < scroll.dtTop + buffer ) {
|
|
869
915
|
dtVert = scrollSpeed * -1;
|
|
870
916
|
}
|
|
871
|
-
else if ( scroll.dtTop !== null &&
|
|
917
|
+
else if ( scroll.dtTop !== null && pageY > scroll.dtTop + scroll.dtHeight - buffer ) {
|
|
872
918
|
dtVert = scrollSpeed;
|
|
873
919
|
}
|
|
874
920
|
|
|
875
|
-
if ( scroll.dtLeft !== null &&
|
|
921
|
+
if ( scroll.dtLeft !== null && pageX < scroll.dtLeft + buffer ) {
|
|
876
922
|
dtHoriz = scrollSpeed * -1;
|
|
877
923
|
}
|
|
878
|
-
else if ( scroll.dtLeft !== null &&
|
|
924
|
+
else if ( scroll.dtLeft !== null && pageX > scroll.dtLeft + scroll.dtWidth - buffer ) {
|
|
879
925
|
dtHoriz = scrollSpeed;
|
|
880
926
|
}
|
|
881
927
|
|
|
@@ -906,12 +952,7 @@ $.extend( AutoFill.prototype, {
|
|
|
906
952
|
this.s.scrollInterval = setInterval( function () {
|
|
907
953
|
// Don't need to worry about setting scroll <0 or beyond the
|
|
908
954
|
// 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
|
-
}
|
|
955
|
+
window.scrollTo(window.scrollX + (scroll.windowHoriz ? scroll.windowHoriz : 0), window.scrollY + (scroll.windowVert ? scroll.windowVert : 0))
|
|
915
956
|
|
|
916
957
|
// DataTables scrolling
|
|
917
958
|
if ( scroll.dtVert || scroll.dtHoriz ) {
|
|
@@ -1102,7 +1143,7 @@ AutoFill.actions = {
|
|
|
1102
1143
|
* @static
|
|
1103
1144
|
* @type String
|
|
1104
1145
|
*/
|
|
1105
|
-
AutoFill.version = '2.3.
|
|
1146
|
+
AutoFill.version = '2.3.9';
|
|
1106
1147
|
|
|
1107
1148
|
|
|
1108
1149
|
/**
|
|
@@ -1,26 +1,50 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
|
|
2
|
+
Copyright 2010-2021 SpryMedia Ltd.
|
|
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
|
|
3
13
|
©2008-2021 SpryMedia Ltd - datatables.net/license
|
|
4
14
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
""
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
".
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
a.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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});
|
package/package.json
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
"description": "AutoFill for DataTables",
|
|
4
4
|
"main": "js/dataTables.autoFill.js",
|
|
5
5
|
"types": "./types/types.d.ts",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.4.0",
|
|
7
7
|
"files": [
|
|
8
|
-
"js/**/*.js"
|
|
8
|
+
"js/**/*.js",
|
|
9
|
+
"types/**/*.d.ts"
|
|
9
10
|
],
|
|
10
11
|
"keywords": [
|
|
11
12
|
"AutoFill",
|
|
@@ -17,8 +18,8 @@
|
|
|
17
18
|
"sort"
|
|
18
19
|
],
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
21
|
+
"datatables.net": ">=1.11.3",
|
|
22
|
+
"jquery": ">=1.7"
|
|
22
23
|
},
|
|
23
24
|
"moduleType": [
|
|
24
25
|
"globals",
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Type definitions for datatables.net-autofill 2.2
|
|
2
|
+
// Project: https://datatables.net
|
|
3
|
+
// Definitions by: Andy Ma <https://github.com/andy-maca>
|
|
4
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
+
// TypeScript Version: 2.4
|
|
6
|
+
|
|
7
|
+
/// <reference types="jquery" />
|
|
8
|
+
/// <reference types="datatables.net"/>
|
|
9
|
+
|
|
10
|
+
declare namespace DataTables {
|
|
11
|
+
interface Settings {
|
|
12
|
+
/**
|
|
13
|
+
* autoFill extension options
|
|
14
|
+
*/
|
|
15
|
+
autoFill?: boolean | AutoFillSettings;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface Api {
|
|
19
|
+
/**
|
|
20
|
+
* Initialise AutoFill on the DataTable
|
|
21
|
+
*
|
|
22
|
+
* @returns Api for chaining with the additional autoFill methods
|
|
23
|
+
*/
|
|
24
|
+
autoFill(): AutoFillFunctions | Api;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface AutoFillFunctions {
|
|
28
|
+
/**
|
|
29
|
+
* Disable AutoFill. Please note that this disallows future interactions with the table (until re-enabled).
|
|
30
|
+
*
|
|
31
|
+
* @returns DataTables Api instance
|
|
32
|
+
*/
|
|
33
|
+
disable(): Api;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Enable end user and API modification of the focused cells in the DataTable. Differing levels of enablement are available via the optional parameter.
|
|
37
|
+
*
|
|
38
|
+
* @param flag can be true or false to signify whether to enable or disable
|
|
39
|
+
* @returns DataTables Api instance
|
|
40
|
+
*/
|
|
41
|
+
enable(flag?: string | boolean): Api;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* This method will return a boolean value indicating if AutoFill is enabled or not on the selected table.
|
|
45
|
+
*
|
|
46
|
+
* @returns boolean signifying if autofill is enables
|
|
47
|
+
*/
|
|
48
|
+
enabled(): boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface AutoFillSettings {
|
|
52
|
+
/**
|
|
53
|
+
* Always ask the end user if an action should be taken or not
|
|
54
|
+
*/
|
|
55
|
+
alwaysAsk?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Select the columns that can be auto filled
|
|
58
|
+
*/
|
|
59
|
+
columns: string | number[];
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* Initial enablement state of AutoFill
|
|
63
|
+
*/
|
|
64
|
+
enable?: boolean;
|
|
65
|
+
}
|
|
66
|
+
}
|