1- /*! AutoFill 2.3.1
2- * ©2008-2018 SpryMedia Ltd - datatables.net/license
1+ /*! AutoFill 2.3.4
2+ * ©2008-2019 SpryMedia Ltd - datatables.net/license
33 */
44
55/**
66 * @summary AutoFill
77 * @description Add Excel like click and drag auto-fill options to DataTables
8- * @version 2.3.1
8+ * @version 2.3.4
99 * @file dataTables.autoFill.js
1010 * @author SpryMedia Ltd (www.sprymedia.co.uk)
1111 * @contact www.sprymedia.co.uk/contact
12- * @copyright Copyright 2010-2018 SpryMedia Ltd.
12+ * @copyright Copyright 2010-2019 SpryMedia Ltd.
1313 *
1414 * This source file is free software, available under the following license:
1515 * MIT license - http://datatables.net/license/mit
@@ -367,7 +367,8 @@ $.extend( AutoFill.prototype, {
367367 start . column
368368 } ;
369369 var colIndx = dt . column . index ( 'toData' , end . column ) ;
370- var endCell = $ ( dt . cell ( ':eq(' + end . row + ')' , colIndx ) . node ( ) ) ;
370+ var endRow = dt . row ( ':eq(' + end . row + ')' , { page : 'current' } ) ; // Workaround for M581
371+ var endCell = $ ( dt . cell ( endRow . index ( ) , colIndx ) . node ( ) ) ;
371372
372373 // Be sure that is a DataTables controlled cell
373374 if ( ! dt . cell ( endCell ) . any ( ) ) {
@@ -388,10 +389,10 @@ $.extend( AutoFill.prototype, {
388389 left = start . column < end . column ? startCell : endCell ;
389390 right = start . column < end . column ? endCell : startCell ;
390391
391- top = this . _getPosition ( top ) . top ;
392- left = this . _getPosition ( left ) . left ;
393- height = this . _getPosition ( bottom ) . top + bottom . outerHeight ( ) - top ;
394- width = this . _getPosition ( right ) . left + right . outerWidth ( ) - left ;
392+ top = this . _getPosition ( top . get ( 0 ) ) . top ;
393+ left = this . _getPosition ( left . get ( 0 ) ) . left ;
394+ height = this . _getPosition ( bottom . get ( 0 ) ) . top + bottom . outerHeight ( ) - top ;
395+ width = this . _getPosition ( right . get ( 0 ) ) . left + right . outerWidth ( ) - left ;
395396
396397 var select = this . dom . select ;
397398 select . top . css ( {
@@ -584,9 +585,8 @@ $.extend( AutoFill.prototype, {
584585 _getPosition : function ( node , targetParent )
585586 {
586587 var
587- currNode = $ ( node ) ,
588+ currNode = node ,
588589 currOffsetParent ,
589- position ,
590590 top = 0 ,
591591 left = 0 ;
592592
@@ -595,23 +595,23 @@ $.extend( AutoFill.prototype, {
595595 }
596596
597597 do {
598- position = currNode . position ( ) ;
598+ // Don't use jQuery().position() the behaviour changes between 1.x and 3.x for
599+ // tables
600+ var positionTop = currNode . offsetTop ;
601+ var positionLeft = currNode . offsetLeft ;
599602
600603 // jQuery doesn't give a `table` as the offset parent oddly, so use DOM directly
601- currOffsetParent = $ ( currNode [ 0 ] . offsetParent ) ;
604+ currOffsetParent = $ ( currNode . offsetParent ) ;
602605
603- top += position . top + currOffsetParent . scrollTop ( ) ;
604- left += position . left + currOffsetParent . scrollLeft ( ) ;
605-
606- top += parseInt ( currOffsetParent . css ( 'margin-top' ) ) * 1 ;
607- top += parseInt ( currOffsetParent . css ( 'border-top-width' ) ) * 1 ;
606+ top += positionTop + parseInt ( currOffsetParent . css ( 'border-top-width' ) ) * 1 ;
607+ left += positionLeft + parseInt ( currOffsetParent . css ( 'border-left-width' ) ) * 1 ;
608608
609609 // Emergency fall back. Shouldn't happen, but just in case!
610- if ( currNode . get ( 0 ) . nodeName . toLowerCase ( ) === 'body' ) {
610+ if ( currNode . nodeName . toLowerCase ( ) === 'body' ) {
611611 break ;
612612 }
613613
614- currNode = currOffsetParent ; // for next loop
614+ currNode = currOffsetParent . get ( 0 ) ; // for next loop
615615 }
616616 while ( currOffsetParent . get ( 0 ) !== targetParent . get ( 0 ) )
617617
@@ -731,14 +731,18 @@ $.extend( AutoFill.prototype, {
731731 var editor = dt . editor ( ) ;
732732
733733 editor
734- . on ( 'submitSuccess.kt' , function ( ) {
735- editor . off ( '.kt' ) ;
736- that . _mouseup ( e ) ;
734+ . on ( 'submitSuccess.dtaf close.dtaf' , function ( ) {
735+ editor . off ( '.dtaf' ) ;
736+
737+ setTimeout ( function ( ) {
738+ that . _mouseup ( e ) ;
739+ } , 100 ) ;
737740 } )
738- . on ( 'submitComplete.kt preSubmitCancelled.kt ' , function ( ) {
739- editor . off ( '.kt ' ) ;
741+ . on ( 'submitComplete.dtaf preSubmitCancelled.dtaf close.dtaf ' , function ( ) {
742+ editor . off ( '.dtaf ' ) ;
740743 } ) ;
741-
744+
745+ // Make the current input submit
742746 editor . submit ( ) ;
743747
744748 return ;
@@ -750,14 +754,16 @@ $.extend( AutoFill.prototype, {
750754 var selected = [ ] ;
751755 var dtSettings = dt . settings ( ) [ 0 ] ;
752756 var dtColumns = dtSettings . aoColumns ;
757+ var enabledColumns = dt . columns ( this . c . columns ) . indexes ( ) ;
753758
754759 // Can't use Array.prototype.map as IE8 doesn't support it
755760 // Can't use $.map as jQuery flattens 2D arrays
756761 // Need to use a good old fashioned for loop
757762 for ( var rowIdx = 0 ; rowIdx < rows . length ; rowIdx ++ ) {
758763 selected . push (
759764 $ . map ( columns , function ( column ) {
760- var cell = dt . cell ( ':eq(' + rows [ rowIdx ] + ')' , column + ':visible' , { page :'current' } ) ;
765+ var row = dt . row ( ':eq(' + rows [ rowIdx ] + ')' , { page :'current' } ) ; // Workaround for M581
766+ var cell = dt . cell ( row . index ( ) , column + ':visible' ) ;
761767 var data = cell . data ( ) ;
762768 var cellIndex = cell . index ( ) ;
763769 var editField = dtColumns [ cellIndex . column ] . editField ;
@@ -766,6 +772,10 @@ $.extend( AutoFill.prototype, {
766772 data = dtSettings . oApi . _fnGetObjectDataFn ( editField ) ( dt . row ( cellIndex . row ) . data ( ) ) ;
767773 }
768774
775+ if ( enabledColumns . indexOf ( cellIndex . column ) === - 1 ) {
776+ return ;
777+ }
778+
769779 return {
770780 cell : cell ,
771781 data : data ,
@@ -938,6 +948,7 @@ $.extend( AutoFill.prototype, {
938948
939949 var dt = this . s . dt ;
940950 var cell ;
951+ var columns = dt . columns ( this . c . columns ) . indexes ( ) ;
941952
942953 // Potentially allow modifications to the cells matrix
943954 this . _emitEvent ( 'preAutoFill' , [ dt , cells ] ) ;
@@ -958,7 +969,9 @@ $.extend( AutoFill.prototype, {
958969 for ( var j = 0 , jen = cells [ i ] . length ; j < jen ; j ++ ) {
959970 cell = cells [ i ] [ j ] ;
960971
961- cell . cell . data ( cell . set ) ;
972+ if ( columns . indexOf ( cell . index . column ) !== - 1 ) {
973+ cell . cell . data ( cell . set ) ;
974+ }
962975 }
963976 }
964977
@@ -1089,7 +1102,7 @@ AutoFill.actions = {
10891102 * @static
10901103 * @type String
10911104 */
1092- AutoFill . version = '2.3.1 ' ;
1105+ AutoFill . version = '2.3.4 ' ;
10931106
10941107
10951108/**
0 commit comments