├── .github └── FUNDING.yml ├── .gitignore ├── js ├── autoFill.dataTables.js ├── autoFill.bulma.js ├── autoFill.foundation.js ├── autoFill.semanticui.js ├── autoFill.bootstrap.js ├── autoFill.bootstrap4.js ├── autoFill.bootstrap5.js ├── autoFill.jqueryui.js └── dataTables.autoFill.js ├── types ├── autoFill.bulma.d.ts ├── autoFill.bootstrap.d.ts ├── autoFill.bootstrap4.d.ts ├── autoFill.bootstrap5.d.ts ├── autoFill.dataTables.d.ts ├── autoFill.foundation.d.ts ├── autoFill.jqueryui.d.ts ├── autoFill.semanticui.d.ts └── types.d.ts ├── css ├── autoFill.jqueryui.scss ├── autoFill.semanticui.scss ├── autoFill.foundation.scss ├── autoFill.bulma.scss ├── autoFill.bootstrap.scss ├── autoFill.bootstrap4.scss ├── autoFill.bootstrap5.scss └── autoFill.dataTables.scss ├── bower.json ├── Issue_template.txt ├── examples ├── styling │ ├── index.xml │ ├── jqueryui.xml │ ├── bootstrap4.xml │ ├── bootstrap5.xml │ ├── bulma.xml │ ├── foundation.xml │ ├── bootstrap.xml │ └── semanticui.xml ├── index.xml └── initialisation │ ├── index.xml │ ├── disableHorizontal.xml │ ├── simple.xml │ ├── scrolling.xml │ ├── keyTable.xml │ ├── focus.xml │ ├── events.xml │ ├── alwaysAsk.xml │ ├── fills.xml │ ├── columns.xml │ ├── enableDisable.xml │ └── plugins.xml ├── test └── api │ ├── autoFill.disable().js │ ├── autoFill.enable().js │ └── autoFill.enabled().js ├── docs ├── option │ ├── language.autoFill.cancel.xml │ ├── autoFill.vertical.xml │ ├── autoFill.horizontal.xml │ ├── language.autoFill.button.xml │ ├── language.autoFill.fillVertical.xml │ ├── language.autoFill.fill.xml │ ├── language.autoFill.fillHorizontal.xml │ ├── language.autoFill.increment.xml │ ├── language.autoFill.info.xml │ ├── autoFill.editor.xml │ ├── autoFill.enable.xml │ ├── autoFill.update.xml │ ├── autoFill.focus.xml │ ├── language.autoFill.xml │ ├── autoFill.alwaysAsk.xml │ ├── autoFill.columns.xml │ └── autoFill.xml ├── event │ ├── preAutoFill.xml │ └── autoFill.xml └── api │ ├── autoFill().enabled().xml │ ├── autoFill().disable().xml │ └── autoFill().enable().xml ├── License.txt ├── make.sh └── Readme.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .sass-cache 3 | -------------------------------------------------------------------------------- /js/autoFill.dataTables.js: -------------------------------------------------------------------------------- 1 | /*! DataTables styling wrapper for AutoFill 2 | * ©2018 SpryMedia Ltd - datatables.net/license 3 | */ 4 | -------------------------------------------------------------------------------- /types/autoFill.bulma.d.ts: -------------------------------------------------------------------------------- 1 | 2 | import DataTable from 'datatables.net-autofill'; 3 | 4 | export default DataTable; 5 | export * from 'datatables.net-autofill'; 6 | -------------------------------------------------------------------------------- /types/autoFill.bootstrap.d.ts: -------------------------------------------------------------------------------- 1 | 2 | import DataTable from 'datatables.net-autofill'; 3 | 4 | export default DataTable; 5 | export * from 'datatables.net-autofill'; 6 | -------------------------------------------------------------------------------- /types/autoFill.bootstrap4.d.ts: -------------------------------------------------------------------------------- 1 | 2 | import DataTable from 'datatables.net-autofill'; 3 | 4 | export default DataTable; 5 | export * from 'datatables.net-autofill'; 6 | -------------------------------------------------------------------------------- /types/autoFill.bootstrap5.d.ts: -------------------------------------------------------------------------------- 1 | 2 | import DataTable from 'datatables.net-autofill'; 3 | 4 | export default DataTable; 5 | export * from 'datatables.net-autofill'; 6 | -------------------------------------------------------------------------------- /types/autoFill.dataTables.d.ts: -------------------------------------------------------------------------------- 1 | 2 | import DataTable from 'datatables.net-autofill'; 3 | 4 | export default DataTable; 5 | export * from 'datatables.net-autofill'; 6 | -------------------------------------------------------------------------------- /types/autoFill.foundation.d.ts: -------------------------------------------------------------------------------- 1 | 2 | import DataTable from 'datatables.net-autofill'; 3 | 4 | export default DataTable; 5 | export * from 'datatables.net-autofill'; 6 | -------------------------------------------------------------------------------- /types/autoFill.jqueryui.d.ts: -------------------------------------------------------------------------------- 1 | 2 | import DataTable from 'datatables.net-autofill'; 3 | 4 | export default DataTable; 5 | export * from 'datatables.net-autofill'; 6 | -------------------------------------------------------------------------------- /types/autoFill.semanticui.d.ts: -------------------------------------------------------------------------------- 1 | 2 | import DataTable from 'datatables.net-autofill'; 3 | 4 | export default DataTable; 5 | export * from 'datatables.net-autofill'; 6 | -------------------------------------------------------------------------------- /js/autoFill.bulma.js: -------------------------------------------------------------------------------- 1 | /*! Bulma integration for DataTables' AutoFill 2 | * ©2015 SpryMedia Ltd - datatables.net/license 3 | */ 4 | 5 | DataTable.AutoFill.classes.btn = 'button is-small'; 6 | -------------------------------------------------------------------------------- /js/autoFill.foundation.js: -------------------------------------------------------------------------------- 1 | /*! Foundation integration for DataTables' AutoFill 2 | * ©2015 SpryMedia Ltd - datatables.net/license 3 | */ 4 | 5 | DataTable.AutoFill.classes.btn = 'button tiny'; 6 | -------------------------------------------------------------------------------- /js/autoFill.semanticui.js: -------------------------------------------------------------------------------- 1 | /*! Bootstrap integration for DataTables' AutoFill 2 | * ©2015 SpryMedia Ltd - datatables.net/license 3 | */ 4 | 5 | DataTable.AutoFill.classes.btn = 'ui button'; 6 | -------------------------------------------------------------------------------- /js/autoFill.bootstrap.js: -------------------------------------------------------------------------------- 1 | /*! Bootstrap integration for DataTables' AutoFill 2 | * ©2015 SpryMedia Ltd - datatables.net/license 3 | */ 4 | 5 | DataTable.AutoFill.classes.btn = 'btn btn-primary'; 6 | -------------------------------------------------------------------------------- /js/autoFill.bootstrap4.js: -------------------------------------------------------------------------------- 1 | /*! Bootstrap integration for DataTables' AutoFill 2 | * ©2015 SpryMedia Ltd - datatables.net/license 3 | */ 4 | 5 | DataTable.AutoFill.classes.btn = 'btn btn-primary'; 6 | -------------------------------------------------------------------------------- /js/autoFill.bootstrap5.js: -------------------------------------------------------------------------------- 1 | /*! Bootstrap integration for DataTables' AutoFill 2 | * ©2015 SpryMedia Ltd - datatables.net/license 3 | */ 4 | 5 | DataTable.AutoFill.classes.btn = 'btn btn-primary'; 6 | -------------------------------------------------------------------------------- /css/autoFill.jqueryui.scss: -------------------------------------------------------------------------------- 1 | 2 | 3 | @use 'autoFill.dataTables.scss' with ($autofill-define-button: false); 4 | 5 | div.dt-autofill-list { 6 | button { 7 | padding: 0.35em 1em; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /js/autoFill.jqueryui.js: -------------------------------------------------------------------------------- 1 | /*! jQuery UI integration for DataTables' AutoFill 2 | * ©2015 SpryMedia Ltd - datatables.net/license 3 | */ 4 | 5 | DataTable.AutoFill.classes.btn = 'ui-button ui-state-default ui-corner-all'; 6 | -------------------------------------------------------------------------------- /css/autoFill.semanticui.scss: -------------------------------------------------------------------------------- 1 | 2 | $autofill-handle-border: 1px solid #888; 3 | 4 | @use 'autoFill.dataTables.scss' with ( 5 | $autofill-define-button: false, 6 | $autofill-outline: #888, 7 | $autofill-handle-background: #888 8 | ); 9 | 10 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "datatables-autofill", 3 | "version": "2.0.0", 4 | "main": [ 5 | "js/dataTables.autoFill.js", 6 | "css/autoFill.dataTables.scss" 7 | ], 8 | "dependencies": { 9 | "jquery": ">=1.7.0", 10 | "datatables": ">=1.10.8" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /css/autoFill.foundation.scss: -------------------------------------------------------------------------------- 1 | 2 | $autofill-handle-border: 1px solid #008CBA; 3 | 4 | @use 'autoFill.dataTables.scss' with ( 5 | $autofill-define-button: false, 6 | $autofill-outline: #008CBA, 7 | $autofill-handle-background: #008CBA 8 | ); 9 | 10 | div.dt-autofill-list { 11 | button { 12 | margin: 0; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /css/autoFill.bulma.scss: -------------------------------------------------------------------------------- 1 | 2 | $autofill-handle-border: 1px solid #00D1B2; 3 | 4 | @use 'autoFill.dataTables.scss' with ( 5 | $autofill-define-button: false, 6 | $autofill-outline: #00D1B2, 7 | $autofill-handle-background: #00D1B2 8 | ); 9 | 10 | div.dt-autofill-list { 11 | button { 12 | margin: 0; 13 | } 14 | } 15 | 16 | div.dt-autofill-handle { 17 | z-index: 11 18 | } -------------------------------------------------------------------------------- /Issue_template.txt: -------------------------------------------------------------------------------- 1 | Please post support requests and questions in the DataTables forums at https://datatables.net/forums. Support requests posted here will be closed. The intention of this request is to allow all questions to be located in a single, searchable, location. 2 | 3 | When you post your question in the DataTables forums, please ensure that you include a link to the page showing the issue so it can be debugged. 4 | -------------------------------------------------------------------------------- /css/autoFill.bootstrap.scss: -------------------------------------------------------------------------------- 1 | 2 | $autofill-handle-border: 1px solid #337ab7; 3 | 4 | @use 'autoFill.dataTables.scss' with ( 5 | $autofill-define-button: false, 6 | $autofill-outline: #337ab7, 7 | $autofill-handle-background: #337ab7 8 | ); 9 | 10 | div.dt-autofill-list { 11 | div.dt-autofill-question { 12 | input[type=number] { 13 | padding: 6px; 14 | width: 60px; 15 | margin: -2px 0; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /css/autoFill.bootstrap4.scss: -------------------------------------------------------------------------------- 1 | 2 | $autofill-handle-border: 1px solid #0275d8; 3 | 4 | @use 'autoFill.dataTables.scss' with ( 5 | $autofill-define-button: false, 6 | $autofill-outline: #0275d8, 7 | $autofill-handle-background: #0275d8 8 | ); 9 | 10 | div.dt-autofill-list { 11 | div.dt-autofill-question { 12 | input[type=number] { 13 | padding: 6px; 14 | width: 60px; 15 | margin: -2px 0; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /examples/styling/index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Styling 5 | 6 | 7 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /css/autoFill.bootstrap5.scss: -------------------------------------------------------------------------------- 1 | 2 | $autofill-handle-border: 1px solid #0d6efd; 3 | 4 | @use 'autoFill.dataTables.scss' with ( 5 | $autofill-define-button: false, 6 | $autofill-outline: #0d6efd, 7 | $autofill-handle-background: #0d6efd 8 | ); 9 | 10 | div.dt-autofill-list { 11 | div.dt-autofill-question { 12 | input[type=number] { 13 | padding: 6px; 14 | width: 60px; 15 | margin: -2px 0; 16 | } 17 | } 18 | } 19 | 20 | // Need the parent of the DataTable to be the offset parent 21 | div.row.dt-row > div.col-sm-12 { 22 | position: relative; 23 | } 24 | -------------------------------------------------------------------------------- /examples/index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Examples 5 | 6 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/api/autoFill.disable().js: -------------------------------------------------------------------------------- 1 | describe('autoFill - api - autoFill().disable()', function() { 2 | dt.libs({ 3 | js: ['jquery', 'datatables', 'autofill'], 4 | css: ['datatables', 'autofill'] 5 | }); 6 | 7 | let table; 8 | 9 | describe('Check the defaults', function() { 10 | dt.html('basic_id'); 11 | it('Ensure its a function', function() { 12 | table = $('#example').DataTable({ 13 | autoFill: true 14 | }); 15 | 16 | expect(typeof table.autoFill().disable).toBe('function'); 17 | }); 18 | it('Returns API instance', function() { 19 | expect(table.autoFill().disable() instanceof $.fn.dataTable.Api).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/styling/jqueryui.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | jQuery UI styling 22 | 23 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /test/api/autoFill.enable().js: -------------------------------------------------------------------------------- 1 | describe('autoFill - api - autoFill().enable()', function() { 2 | dt.libs({ 3 | js: ['jquery', 'datatables', 'autofill'], 4 | css: ['datatables', 'autofill'] 5 | }); 6 | 7 | let table; 8 | 9 | // Basic tests - more complex tests in autoFill().enabled() 10 | describe('Check the defaults', function() { 11 | dt.html('basic_id'); 12 | it('Ensure its a function', function() { 13 | table = $('#example').DataTable({ 14 | autoFill: true 15 | }); 16 | 17 | expect(typeof table.autoFill().enable).toBe('function'); 18 | }); 19 | it('Returns API instance', function() { 20 | expect(table.autoFill().enable() instanceof $.fn.dataTable.Api).toBe(true); 21 | }); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /examples/initialisation/index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Initialisation examples 5 | 6 | 7 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/styling/bootstrap4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | Bootstrap 4 styling 22 | 23 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /examples/styling/bootstrap5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | Bootstrap 5 styling 22 | 23 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /examples/styling/bulma.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | Bulma styling 22 | 23 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /examples/initialisation/disableHorizontal.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 13 | 14 | 15 | 16 | 23 | 24 | 25 | Disable horizontal fill 26 | 27 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /examples/styling/foundation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | Foundation styling 22 | 23 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /examples/styling/bootstrap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | Bootstrap 3 styling 22 | 23 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /examples/styling/semanticui.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | Fomantic-UI (formally Semantic-UI) styling 22 | 23 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /examples/initialisation/simple.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | 20 | 21 | 22 | Basic initialisation 23 | 24 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /docs/option/language.autoFill.cancel.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | language.autoFill.cancel 4 | Multi-fill selector cancel option message 5 | 2.0.0 6 | 7 | 8 | 9 | 10 | 11 | The message to display for the cancel option in the multi-fill selector panel. 12 | 13 | 14 | 15 | 16 | If the multi-fill selector is shown it will always contain a cancel option that the end user can select to have no update performed on the table. This option provides the ability to customise the cancel message shown in the selector. 17 | 18 | 19 | 29 | -------------------------------------------------------------------------------- /docs/option/autoFill.vertical.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill.vertical 4 | Enable / disable user ability to vertically drag and fill 5 | 2.3.0 6 | 7 | 8 | 9 | * `true` - vertical drag and fill is enabled 10 | * `false` - vertical drag and fill is disabled 11 | 12 | 13 | 14 | 15 | Vertical filling is enabled 16 | 17 | 18 | 19 | This option can be used to disable the end user's ability to drag and fill across columns. The drag and fill action will be restricted to the column that they started the drag on if this feature is disabled. 20 | 21 | 22 | 29 | 30 | -init autoFill.horizontal 31 | -------------------------------------------------------------------------------- /docs/option/autoFill.horizontal.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill.horizontal 4 | Enable / disable user ability to horizontally drag and fill 5 | 2.3.0 6 | 7 | 8 | 9 | * `true` - Horizontal drag and fill is enabled 10 | * `false` - Horizontal drag and fill is disabled 11 | 12 | 13 | 14 | 15 | Horizontal filling is enabled 16 | 17 | 18 | 19 | This option can be used to disable the end user's ability to drag and fill across columns. The drag and fill action will be restricted to the column that they started the drag on if this feature is disabled. 20 | 21 | 22 | 29 | 30 | -init autoFill.vertical 31 | -------------------------------------------------------------------------------- /docs/option/language.autoFill.button.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | language.autoFill.button 4 | Multi-fill selector button text 5 | 2.0.0 6 | 7 | 8 | 9 | 10 | 11 | The text to show in the select button for the fill options list. This string can contain HTML for additional styling options. 12 | 13 | 14 | 15 | 16 | This option gives the ability to customise the text shown in the multi-fill selector buttons. The end user will click these buttons to select what fill type to use when multiple fills are available. 17 | 18 | 19 | 29 | 30 | af-init autoFill.alwaysAsk 31 | -------------------------------------------------------------------------------- /examples/initialisation/scrolling.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | Scrolling DataTable 30 | 31 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/option/language.autoFill.fillVertical.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | language.autoFill.fillVertical 4 | Multi-fill selector message for the _vertical fill_ fill type 5 | 2.0.0 6 | 7 | 8 | 9 | 10 | 11 | Message shown by the vertical fill type in the fill selector. This string can contain HTML for additional styling options. 12 | 13 | 14 | 15 | 16 | The vertical fill type will copy the data from the first row in the selected cells to the other cells vertically. This option sets the message that will be shown when this fill type is available. 17 | 18 | 19 | 29 | -------------------------------------------------------------------------------- /docs/option/language.autoFill.fill.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | language.autoFill.fill 4 | Multi-fill selector message for the _full fill_ fill type 5 | 2.0.0 6 | 7 | 8 | 9 | 10 | 11 | Message shown by the full fill type in the fill selector. This string can contain HTML for additional styling options. 12 | 13 | 14 | 15 | 16 | The full fill type will copy the data from the cell where the fill originated to all other cells. This option sets the message that will be shown when this fill type is available (which is always!). 17 | 18 | 19 | 29 | 30 | -------------------------------------------------------------------------------- /docs/option/language.autoFill.fillHorizontal.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | language.autoFill.fillHorizontal 4 | Multi-fill selector message for the _horizontal fill_ fill type 5 | 2.0.0 6 | 7 | 8 | 9 | 10 | 11 | Message shown by the horizontal fill type in the fill selector. This string can contain HTML for additional styling options. 12 | 13 | 14 | 15 | 16 | The horizontal fill type will copy the data from the first column in the selected cells to the other cells horizontally. This option sets the message that will be shown when this fill type is available. 17 | 18 | 19 | 29 | -------------------------------------------------------------------------------- /docs/option/language.autoFill.increment.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | language.autoFill.increment 4 | Multi-fill selector message for the _increment_ fill type 5 | 2.0.0 6 | 7 | 8 | 9 | 10 | 11 | Message shown by the increment fill type when it is available for the data fill. It should also include the HTML required for a number input to determine what the increment value should be. 12 | 13 | 14 | 15 | 16 | This option provides the ability to customise the message that the increment fill type will show when it is available for a data fill. 17 | 18 | 19 | ' 24 | } 25 | }, 26 | autoFill: true 27 | }); 28 | ]]> 29 | -------------------------------------------------------------------------------- /docs/option/language.autoFill.info.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | language.autoFill.info 4 | Information message shown at the top of the fill type selector 5 | 2.0.0 6 | 7 | 8 | 9 | 10 | 11 | String to be shown at the top of the data fill selection method. This string can contain HTML for additional styling options. 12 | 13 | 14 | 15 | 16 | AutoFill's fill selector box (shown when there are multiple fill options available) has the ability to show an information message at the top of the box. This can be used to explain to the end user why the box is being shown and what action they should take. 17 | 18 | 19 | 29 | 30 | af-init autoFill.alwaysAsk 31 | -------------------------------------------------------------------------------- /examples/initialisation/keyTable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 13 | 14 | 15 | 21 | 22 | 23 | KeyTable integration 24 | 25 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | MIT license 2 | 3 | Copyright (c) 2008-2015 SpryMedia Limited 4 | http://datatables.net 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /docs/option/autoFill.editor.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill.editor 4 | Attach an Editor instance for database updating 5 | 2.0.0 6 | 7 | 8 | 9 | The Editor instance to use for editing of the table 10 | 11 | 12 | 13 | 14 | No Editor instance is automatically attached. 15 | 16 | 17 | 18 | When completing a AutoFill action you will typically wish to update the data source to reflect the changes made by the end user. This can be done with AutoFill's integration with [Editor](//editor.datatables.net). 19 | 20 | This option can specify an Editor instance that should be used to submit the changes to the server. Upon drag completion the changes will be immediately submitted to the server and the table redrawn with the updated data retrieved from the server. 21 | 22 | 23 | 30 | -------------------------------------------------------------------------------- /docs/option/autoFill.enable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill.enable 4 | Initial enablement state of AutoFill 5 | 2.2.0 6 | 7 | 8 | 9 | * `true` - AutoFill is enabled when the DataTable is created 10 | * `false` - AutoFill is not enabled, and can later be enabled via the API. 11 | 12 | 13 | 14 | 15 | AutoFill is enabled 16 | 17 | 18 | 19 | It can be useful to disable AutoFill's user input controls at certain times, depending on the state of your application. This option provides that ability when the table is initially created, while the `-api autoFill().enable()` and `-api autoFill().disable()` methods provide the option to enabling the user interaction after the table has been created. 20 | 21 | 22 | 29 | 30 | -init autoFill.enable 31 | -api autoFill().enabled() 32 | -api autoFill().enable() 33 | -api autoFill().disable() 34 | -------------------------------------------------------------------------------- /docs/option/autoFill.update.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill.update 4 | Control automatic update of data when a fill drag is completed 5 | 2.0.0 6 | 7 | 8 | 9 | * `true` - DataTables data is automatically updated as a result of the auto fill action and the table redrawn. 10 | * `false` - No data update or draw is performed. 11 | 12 | 13 | 14 | 15 | Data is updated and table redrawn 16 | 17 | 18 | 19 | At the end of a fill action you will typically wish to take some action to reflect the change from the data fill. By default AutoFill will write the filled values to the DataTable and then redraw the table to account for any changes in ordering. 20 | 21 | This action is not always desirable, particularly if you are using server-side processing or wish to have an external process update the data. In such circumstances this option can be used to disable the automatic data update and draw. 22 | 23 | 24 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /make.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../.." 4 | if [ "$1" = "debug" ]; then 5 | DEBUG="debug" 6 | else 7 | OUT_DIR=$1 8 | DEBUG=$2 9 | fi 10 | 11 | # If not run from DataTables build script, redirect to there 12 | if [ -z "$DT_BUILD" ]; then 13 | cd $DT_DIR/build 14 | ./make.sh extension AutoFill $DEBUG 15 | cd - 16 | exit 17 | fi 18 | 19 | # Change into script's own dir 20 | cd $(dirname $0) 21 | 22 | DT_SRC=$(dirname $(dirname $(pwd))) 23 | DT_BUILT="${DT_SRC}/built/DataTables" 24 | . $DT_SRC/build/include.sh 25 | 26 | # Copy CSS 27 | rsync -r css $OUT_DIR 28 | css_frameworks autoFill $OUT_DIR/css 29 | 30 | # Copy JS 31 | rsync -r js $OUT_DIR 32 | js_wrap $OUT_DIR/js/dataTables.autoFill.js "jquery datatables.net" 33 | js_frameworks autoFill $OUT_DIR/js "jquery datatables.net-FW datatables.net-autofill" 34 | 35 | # Copy Types 36 | if [ -d $OUT_DIR/types ]; then 37 | rm -r $OUT_DIR/types 38 | fi 39 | mkdir $OUT_DIR/types 40 | 41 | if [ -d types/ ]; then 42 | cp types/* $OUT_DIR/types 43 | else 44 | if [ -f types.d.ts ]; then 45 | cp types.d.ts $OUT_DIR/types 46 | fi 47 | fi 48 | 49 | # Copy and build examples 50 | rsync -r examples $OUT_DIR 51 | examples_process $OUT_DIR/examples 52 | 53 | # Readme and license 54 | cp Readme.md $OUT_DIR 55 | cp License.txt $OUT_DIR 56 | -------------------------------------------------------------------------------- /examples/initialisation/focus.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 13 | 14 | 15 | 16 | 23 | 24 | 25 | Click focus 26 | 27 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /examples/initialisation/events.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | Events 30 | 31 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /docs/event/preAutoFill.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | preAutoFill 4 | An auto fill action is about to be applied to the table 5 | 2.0.0 6 | 7 | 8 | function( e, datatable, cells ) 9 | 10 | jQuery event object 11 | 12 | 13 | DataTables API instance for the table the AutoFill was completed on 14 | 15 | 16 | A matrix of the cells that were auto filled. Please see the description in the `af-event autoFill` event for full details on the structure of this array. 17 | 18 | HTML table element 19 | 20 | 21 | 22 | This event is triggered when an fill action is about to write changes to a DataTable - it occurs after the fill drag has been completed and the new cell values computed, but before those values are written into the table. 23 | 24 | This event provides the ability to modify the new values, should that ability be required, by modifying the `set` parameter in the object that represents each cell from the fill. Please see the description in the `af-event autoFill` event for details about this parameter and how it can be accessed. 25 | 26 | -------------------------------------------------------------------------------- /docs/api/autoFill().enabled().xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill().enabled() 4 | Determine if AutoFill is enabled or disabled 5 | 2.2.0 6 | 7 | 8 | autoFill().enabled() 9 | autoFill().enabled() 10 | 11 | This method will return a boolean value indicating if AutoFill is enabled or not on the selected table. 12 | 13 | `true` if AutoFill is enabled, `false` otherwise. 14 | 15 | 16 | 17 | This method can be used to determine if the AutoFill extension for a DataTable is enabled on a table or not. A simple boolean value is given indicating the status. 18 | 19 | 20 | 36 | 37 | -init autoFill.enable 38 | -api autoFill().enabled() 39 | -api autoFill().enable() 40 | -api autoFill().disable() 41 | 42 | -------------------------------------------------------------------------------- /docs/api/autoFill().disable().xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill().disable() 4 | Disable AutoFill's interactions 5 | 2.2.0 6 | 7 | 8 | autoFill().disable() 9 | autoFill().disable() 10 | 11 | Disable AutoFill. Please note that this disallows future interactions with the table (until re-enabled). 12 | 13 | DataTables API instance 14 | 15 | 16 | 17 | This method can be used to disable AutoFill's end user interaction options with a DataTable during run time. This can be useful if your UI does not allow for AutoFill to be used under certain circumstances. 18 | 19 | 20 | 36 | 37 | -init autoFill.enable 38 | -api autoFill().enabled() 39 | -api autoFill().enable() 40 | -api autoFill().disable() 41 | -------------------------------------------------------------------------------- /docs/option/autoFill.focus.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill.focus 4 | Action that will cause the auto fill drag handle to appear in a cell 5 | 2.0.0 6 | 7 | 8 | 9 | Action that will cause the drag handle to appear in a cell. It can be one of: 10 | 11 | * `-string click` - Display when a cell is clicked upon 12 | * `-string focus` - Display when a cell gains focus - for integration with [KeyTable](https://datatables.net/extensions/keytable) 13 | * `-string hover` - Display when a cell is hovered over 14 | * `-type null` - Automatic detection - `focus` if KeyTable is enabled on a table and `hover` otherwise. 15 | 16 | 17 | 18 | 19 | If KeyTable is also initialised on the host table the `-string focus` option will be used. Otherwise `-string hover` is used. 20 | 21 | 22 | 23 | The click-to-drag auto fill drag handle can be attached to the table cells using a number of different methods, depending on how you wish the end user to interact with your table. This option provides the ability to switch between the various options which are detailed below. 24 | 25 | 26 | 33 | -------------------------------------------------------------------------------- /examples/initialisation/alwaysAsk.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 13 | 14 | 15 | 16 | 23 | 24 | 25 | Always confirm action 26 | 27 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/api/autoFill.enabled().js: -------------------------------------------------------------------------------- 1 | describe('autoFill - api - autoFill().enabled()', function() { 2 | dt.libs({ 3 | js: ['jquery', 'datatables', 'autofill'], 4 | css: ['datatables', 'autofill'] 5 | }); 6 | 7 | let table; 8 | 9 | describe('Check the defaults', function() { 10 | dt.html('basic_id'); 11 | it('Ensure its a function', function() { 12 | table = $('#example').DataTable({ 13 | autoFill: true 14 | }); 15 | 16 | expect(typeof table.autoFill().enabled).toBe('function'); 17 | }); 18 | it('Returns API instance', function() { 19 | expect(typeof table.autoFill().enabled()).toBe('boolean'); 20 | }); 21 | }); 22 | 23 | describe('Functional tests', function() { 24 | dt.html('basic'); 25 | it('Not configured', async function() { 26 | table = $('#example').DataTable(); 27 | expect(table.autoFill().enabled()).toBe(false); 28 | }); 29 | it('... and unable to enable', async function() { 30 | table.autoFill().enable(); 31 | expect(table.autoFill().enabled()).toBe(false); 32 | }); 33 | 34 | dt.html('basic'); 35 | it('Enabled when configured', async function() { 36 | table = $('#example').DataTable({ 37 | autoFill: true 38 | }); 39 | expect(table.autoFill().enabled()).toBe(true); 40 | }); 41 | it('... and able to disable', async function() { 42 | table.autoFill().disable(); 43 | expect(table.autoFill().enabled()).toBe(false); 44 | }); 45 | it('... and able to enable', async function() { 46 | table.autoFill().enable(); 47 | expect(table.autoFill().enabled()).toBe(true); 48 | }); 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /docs/option/language.autoFill.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | language.autoFill 4 | Container object for language strings used by AutoFill 5 | 2.0.0 6 | 7 | 8 | 9 | This is a container object for the language strings used by AutoFill: 10 | 11 | * `af-init language.autoFill.button` - Fill type selector button text 12 | * `af-init language.autoFill.cancel` - Cancel fill information message 13 | * `af-init language.autoFill.fill` - Complete fill selector message 14 | * `af-init language.autoFill.fillHorizontal` - Horizontal fill selector message 15 | * `af-init language.autoFill.fillVertical` - Vertical fill selector message 16 | * `af-init language.autoFill.increment` - Increment fill selector message 17 | * `af-init language.autoFill.info` - Fill type selector summary 18 | 19 | 20 | 21 | 22 | AutoFill make use of a number of strings that are displayed to the end user to explain what action will be performed based on the user input. 23 | 24 | A parameters of this object provide the ability to customise those strings to suit your needs. This can be a full translation or a tweak of just one or two strings to match the styling of your site / app. 25 | 26 | 27 | 37 | -------------------------------------------------------------------------------- /docs/option/autoFill.alwaysAsk.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill.alwaysAsk 4 | Always ask the end user if an action should be taken or not 5 | 2.0.0 6 | 7 | 8 | 9 | * `false` - Proceed with the fill, without asking the end user if there is only one option 10 | * `true` - Always ask the end user, before doing the fill, even if there is only one option. 11 | 12 | 13 | 14 | 15 | Fill will occur automatically if there is only one fill option. 16 | 17 | 18 | 19 | When an auto fill is completed by the end user, AutoFill will determine how many data fill plug-ins can be used for the data that has been dragged over. If there are multiple options it will display a list of those options to the end user allowing them to select the action to perform - a cancel button is also shown. 20 | 21 | By default, if there is only a single data fill plug-in that can operate on the data, it will be immediately acted upon, no confirmation required by the end user and no option to cancel the action. 22 | 23 | This option can be used to force AutoFill to confirm the action to take, even if there is only one option. This provides the end user with the ability to cancel the action if they made a mistake during the drag. 24 | 25 | 26 | 33 | -------------------------------------------------------------------------------- /docs/option/autoFill.columns.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill.columns 4 | Select the columns that can be auto filled 5 | 2.0.0 6 | 7 | 8 | 9 | The columns that be auto filled. This accepts all of the options of `dt-type column-selector` such as class name selector, jQuery pseudo selects and column index selectors. 10 | 11 | 12 | 13 | 14 | Empty string (i.e. all columns) 15 | 16 | 17 | 18 | When working with complex tables it is not uncommon to have certain columns that you might not wish to allow a data fill on - for example a checkbox column that is used for row selection or a column with editing action buttons. This option can be used to define which columns can be auto filled. If a column cannot be auto filled, cells in it will not show the fill drag handle and will not be selectable during a drag. 19 | 20 | Please note that only visible cells can be auto filled, so the columns defined by this option are automatically merged with the visible columns in the table. Non-visible columns will cannot be auto filled. 21 | 22 | 23 | 30 | 31 | 38 | -------------------------------------------------------------------------------- /examples/initialisation/fills.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | Fill types 22 | 23 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # AutoFill 2 | 3 | AutoFill adds an Excel data fill like option to a DataTable to click and drag over multiple cells, filling in information over the selected cells and incrementing numbers as needed. 4 | 5 | 6 | # Installation 7 | 8 | To use AutoFill the best way to obtain the software is to use the [DataTables downloader](//datatables.net/download). You can also include the individual files from the [DataTables CDN](//cdn.datatables.net). See the [documentation](http://datatables.net/extensions/autofill/) for full details. 9 | 10 | ## NPM and Bower 11 | 12 | If you prefer to use a package manager such as NPM or Bower, distribution repositories are available with software built from this repository under the name `datatables.net-autofill`. Styling packages for Bootstrap, Foundation and other styling libraries are also available by adding a suffix to the package name. 13 | 14 | Please see the DataTables [NPM](//datatables.net/download/npm) and [Bower](//datatables.net/download/bower) installation pages for further information. The [DataTables installation manual](//datatables.net/manual/installation) also has details on how to use package managers with DataTables. 15 | 16 | 17 | # Basic usage 18 | 19 | AutoFill is initialised using the `autoFill` option in the DataTables constructor. Further options can be specified using this option as an object - see the documentation for details. For example: 20 | 21 | ```js 22 | $(document).ready( function () { 23 | $('#example').DataTable( { 24 | autoFill: true 25 | } ); 26 | } ); 27 | ``` 28 | 29 | 30 | # Documentation / support 31 | 32 | * [Documentation](https://datatables.net/extensions/autofill/) 33 | * [DataTables support forums](http://datatables.net/forums) 34 | 35 | 36 | # GitHub 37 | 38 | If you fancy getting involved with the development of AutoFill and help make it better, please refer to its [GitHub repo](https://github.com/DataTables/AutoFill) 39 | 40 | -------------------------------------------------------------------------------- /docs/api/autoFill().enable().xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill().enable() 4 | Enable or disable AutoFill's interactions 5 | 2.2.0 6 | 7 | 8 | autoFill().enable() 9 | autoFill().enable( [ flag ] ) 10 | 11 | Enable end user and API modification of the focused cells in the DataTable. Differing levels of enablement are available via the optional parameter. 12 | 13 | 14 | This option can be given as the following values: 15 | 16 | * `true` - Enable AutoFill 17 | * `false` - Disable AutoFill 18 | 19 | DataTables API instance 20 | 21 | 22 | 23 | This method can be used to enable and disable the AutoFill end user interaction with a DataTable. In its simplest form it can be used to enable AutoFill, but it can also be used to disable it using the optional parameter. This is useful to be able to toggle the enablement state using a ternary operator or some external variable. 24 | 25 | Please note that in order to be able to enable AutoFill, the `-init autoFill` option _must_ be specified in the DataTable initialisation. This method cannot be used to enable AutoFill if `-init autoFill` has not be used. 26 | 27 | 28 | 39 | 40 | -init autoFill.enable 41 | -api autoFill().enabled() 42 | -api autoFill().enable() 43 | -api autoFill().disable() 44 | -------------------------------------------------------------------------------- /docs/option/autoFill.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill 4 | Enable and configure the AutoFill extension for DataTables 5 | 2.0.0 6 | 7 | 8 | 9 | As a boolean value this property will enable AutoFill on the DataTable that is being created. `true` will enable AutoFill, while `false` will not. 10 | 11 | This is a short-cut option to enable AutoFill with the default configuration options. Customisations can be made by giving this parameter as an object, see below. 12 | 13 | 14 | 15 | 16 | 17 | If given as an object, AutoFill will be enabled on the target DataTable, with default values (`$.fn.dataTable.AutoFill.defaults`) extended, and potentially overwritten, by the options provided in this object. This is how AutoFill can be configured on an individual table basis, or through the defaults. 18 | 19 | 20 | 21 | 22 | AutoFill will not be initialised by default 23 | 24 | 25 | 26 | This option provides the ability to enable and configure AutoFill for DataTables. In its simplest form as the boolean `true` it will enable AutoFill with the default configuration options (as defined by `$.fn.dataTable.AutoFill.defaults`). It can also be used as an object to provide custom configuration options as described below. 27 | 28 | Please note that as with all other configuration options for AutoFill, this option is an extension to the [default set of DataTables options](/reference/option). This property should be set in the DataTables initialisation object. 29 | 30 | 31 | 36 | 37 | 44 | 45 | -------------------------------------------------------------------------------- /examples/initialisation/columns.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 25 | 26 | 27 | 28 | 47 | 48 | 49 | Column selector 50 | 51 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /examples/initialisation/enableDisable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 32 | 33 | 34 | 35 | 61 | 62 | 63 | Enable / disable API 64 | 65 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /docs/event/autoFill.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | autoFill 4 | An auto fill action has been completed 5 | 2.0.0 6 | 7 | 8 | function( e, datatable, cells ) 9 | 10 | jQuery event object 11 | 12 | 13 | DataTables API instance for the table the AutoFill was completed on 14 | 15 | 16 | A matrix of the cells that were auto filled. Please see the description above for details. 17 | 18 | HTML table element 19 | 20 | 21 | 22 | This event is triggered when an fill action is completed by the end user. This occurs after the table has been updated and redraw by the fill. This can be useful to have the ability to submit the changes to a server / database to store the changes permanently. 23 | 24 | The information about the cells that have been filled is given as an array (the `cells` parameter below) - this is an array of arrays, with each of the top level arrays representing a row and the inner elements being the columns - e.g.: 25 | 26 | ```js 27 | [ 28 | [ cell_0-0, cell_0-1, cell_0-2, ... ], 29 | [ cell_1-0, cell_1-1, cell_1-2, ... ], 30 | [ cell_2-0, cell_2-1, cell_2-2, ... ], 31 | ... 32 | ] 33 | ``` 34 | 35 | There is always guaranteed to be more than one cell - therefore it is safe to access `[0][0]` as the first cell. This first cell is the one where the fill was started. The first row and column are on the same axis as that cell, regardless of if the fill was up, down, left or right. 36 | 37 | Each inner array item is an object that represents a cell and contains the following properties: 38 | 39 | * `cell` - A DataTables Api instance for the cell in question - see `dt-api cell()` 40 | * `index` - The cell's index - see `dt-api cell().index()` - note this is the _DataTables internal index_ not a visible index! 41 | * `data` - The cell's data before the fill 42 | * `set` - The cell's data after the fill 43 | 44 | 45 | 52 | -------------------------------------------------------------------------------- /examples/initialisation/plugins.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 35 | 36 | 37 | 38 | 67 | 68 | 69 | Fill plug-ins 70 | 71 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /css/autoFill.dataTables.scss: -------------------------------------------------------------------------------- 1 | 2 | $autofill-define-button: true !default; 3 | $autofill-outline: #4989de !default; 4 | $autofill-handle-background: #3366ff !default; 5 | $autofill-handle-background-focus: #ff8b33 !default; 6 | 7 | 8 | div.dt-autofill-handle { 9 | position: absolute; 10 | height: 10px; 11 | width: 10px; 12 | z-index: 10; 13 | 14 | box-sizing: border-box; 15 | background: $autofill-handle-background; 16 | cursor: pointer; 17 | } 18 | 19 | // KeyTable alt focus 20 | div.dtk-focus-alt { 21 | div.dt-autofill-handle { 22 | background: $autofill-handle-background-focus; 23 | } 24 | } 25 | 26 | div.dt-autofill-select { 27 | position: absolute; 28 | z-index: 1001; 29 | 30 | background-color: $autofill-outline; 31 | background-image: repeating-linear-gradient(45deg, 32 | transparent, 33 | transparent 5px, 34 | rgba(255,255,255,.5) 5px, 35 | rgba(255,255,255,.5) 10px 36 | ); 37 | 38 | &.top, 39 | &.bottom { 40 | height: 3px; 41 | margin-top: -1px; 42 | } 43 | 44 | &.left, 45 | &.right { 46 | width: 3px; 47 | margin-left: -1px; 48 | } 49 | } 50 | 51 | div.dt-autofill-list { 52 | position: fixed; 53 | top: 50%; 54 | left: 50%; 55 | width: 500px; 56 | margin-left: -250px; 57 | // margin-top is set by JS 58 | background-color: white; 59 | border-radius: 0.75em; 60 | box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6); 61 | z-index: 104; 62 | box-sizing: border-box; 63 | padding: 2em; 64 | 65 | div.dtaf-popover-close { 66 | position: absolute; 67 | top: 6px; 68 | right: 6px; 69 | width: 22px; 70 | height: 22px; 71 | text-align: center; 72 | border-radius: 3px; 73 | cursor: pointer; 74 | z-index: 12; 75 | } 76 | 77 | > div.dt-autofill-list-items { 78 | > button { 79 | display: block; 80 | width: 100%; 81 | margin: 1em 0; 82 | padding: 1em; 83 | border-radius: 0.5em; 84 | border: 1px solid rgba(0, 0, 0, 0.175); 85 | background-color: #f6f6f6; 86 | text-align: left; 87 | cursor: pointer; 88 | 89 | &:hover { 90 | background-color: #ebebeb; 91 | } 92 | 93 | &:first-child { 94 | margin-top: 0; 95 | } 96 | 97 | &:last-child { 98 | margin-bottom: 0; 99 | } 100 | 101 | input[type=number] { 102 | display: inline-block; 103 | box-sizing: border-box; 104 | padding: 6px; 105 | width: 70px; 106 | margin: -2px 0; 107 | } 108 | 109 | span { 110 | float: right; 111 | } 112 | } 113 | } 114 | } 115 | 116 | div.dtaf-popover-closeable { 117 | padding-top: 2.5em; 118 | } 119 | 120 | div.dt-autofill-background { 121 | position: fixed; 122 | top: 0; 123 | left: 0; 124 | width: 100%; 125 | height: 100%; 126 | 127 | background: rgba(0, 0, 0, 0.7); // fallback 128 | background: radial-gradient(ellipse farthest-corner at center, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.7) 100%); 129 | 130 | z-index: 103; 131 | } 132 | 133 | html.dark { 134 | div.dt-autofill-handle { 135 | background: rgb(110, 168, 254); 136 | } 137 | 138 | div.dt-autofill-select { 139 | position: absolute; 140 | z-index: 1001; 141 | 142 | background-color: rgb(110, 168, 254); 143 | background-image: repeating-linear-gradient(45deg, 144 | transparent, 145 | transparent 5px, 146 | rgba(0,0,0,.5) 5px, 147 | rgba(0,0,0,.5) 10px 148 | ); 149 | } 150 | 151 | div.dt-autofill-list { 152 | background-color: var(--dt-html-background); 153 | border: 1px solid rgba(255, 255, 255, 0.15); 154 | 155 | button { 156 | color: inherit; 157 | border: 1px solid rgba(255, 255, 255, 0.175); 158 | background-color: rgb(47, 52, 56); 159 | 160 | &:hover { 161 | background-color: rgb(64, 69, 73); 162 | } 163 | } 164 | } 165 | } 166 | 167 | @media screen and (max-width: 767px) { 168 | div.dt-autofill-handle { 169 | height: 16px; 170 | width: 16px; 171 | } 172 | 173 | div.dt-autofill-list { 174 | width: 90%; 175 | left: 74.5%; 176 | } 177 | } -------------------------------------------------------------------------------- /types/types.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for DataTables AutoFill 2 | // 3 | // Project: https://datatables.net/extensions/autofill/, https://datatables.net 4 | // Definitions by: 5 | // SpryMedia 6 | // Andy Ma 7 | 8 | /// 9 | 10 | import DataTables, {Api} from 'datatables.net'; 11 | 12 | export default DataTables; 13 | export * from 'datatables.net'; 14 | 15 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 16 | * DataTables' types integration 17 | */ 18 | declare module 'datatables.net' { 19 | interface Config { 20 | /** 21 | * autoFill extension options 22 | */ 23 | autoFill?: boolean | ConfigAutoFill; 24 | } 25 | 26 | interface ConfigLanguage { 27 | /** 28 | * AutoFill language options 29 | */ 30 | autoFill?: ConfigAutoFillLanguage; 31 | } 32 | 33 | interface Api { 34 | /** 35 | * AutoFill methods container 36 | * 37 | * @returns Api for chaining with the additional autoFill methods 38 | */ 39 | autoFill: ApiAutoFill; 40 | } 41 | 42 | interface DataTablesStatic { 43 | /** 44 | * AutoFill class 45 | */ 46 | AutoFill: { 47 | /** 48 | * Create a new AutoFill instance for the target DataTable 49 | */ 50 | new (dt: Api, settings: boolean | ConfigAutoFill): AutoFill; 51 | 52 | /** 53 | * AutoFill version 54 | */ 55 | version: string; 56 | 57 | /** 58 | * Default configuration values 59 | */ 60 | defaults: ConfigAutoFill; 61 | } 62 | } 63 | } 64 | 65 | 66 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 67 | * Options 68 | */ 69 | 70 | interface ConfigAutoFill { 71 | /** 72 | * Always ask the end user if an action should be taken or not 73 | */ 74 | alwaysAsk?: boolean; 75 | 76 | /** 77 | * Select the columns that can be auto filled 78 | */ 79 | columns?: string | number[]; 80 | 81 | /** 82 | * 83 | * Attach an Editor instance for database updating 84 | */ 85 | editor?: any; 86 | 87 | /** 88 | * 89 | * Initial enablement state of AutoFill 90 | */ 91 | enable?: boolean; 92 | 93 | /** 94 | * Action that will cause the auto fill drag handle to appear in a cell 95 | */ 96 | focus?: 'click' | 'focus' | 'hover' | null; 97 | 98 | /** 99 | * Enable / disable user ability to horizontally drag and fill 100 | */ 101 | horizontal?: boolean; 102 | 103 | /** 104 | * Control automatic update of data when a fill drag is completed 105 | */ 106 | update?: boolean; 107 | 108 | /** 109 | * Enable / disable user ability to vertically drag and fill 110 | */ 111 | vertical?: boolean; 112 | } 113 | 114 | interface ConfigAutoFillLanguage { 115 | /** 116 | * Multi-fill selector button text 117 | */ 118 | button?: string; 119 | 120 | /** 121 | * Multi-fill selector cancel option message 122 | */ 123 | cancel?: string; 124 | 125 | /** 126 | * Multi-fill selector message for the _full fill_ fill type 127 | */ 128 | fill?: string; 129 | 130 | /** 131 | * Multi-fill selector message for the _horizontal fill_ fill type 132 | */ 133 | fillHorizontal?: string; 134 | 135 | /** 136 | * Multi-fill selector message for the _vertical fill_ fill type 137 | */ 138 | fillVertical?: string; 139 | 140 | /** 141 | * Multi-fill selector message for the _increment_ fill type 142 | */ 143 | increment?: string; 144 | 145 | /** 146 | * Information message shown at the top of the fill type selector 147 | */ 148 | info?: string; 149 | } 150 | 151 | 152 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 153 | * API 154 | */ 155 | 156 | interface ApiAutoFill { 157 | (): ApiAutoFillMethods; 158 | } 159 | 160 | interface ApiAutoFillMethods extends Api { 161 | /** 162 | * Disable AutoFill. Please note that this disallows future interactions with the table (until re-enabled). 163 | * 164 | * @returns DataTables Api instance 165 | */ 166 | disable(): Api; 167 | 168 | /** 169 | * Enable end user and API modification of the focused cells in the DataTable. Differing levels of enablement are available via the optional parameter. 170 | * 171 | * @param flag can be true or false to signify whether to enable or disable 172 | * @returns DataTables Api instance 173 | */ 174 | enable(flag?: string | boolean): Api; 175 | 176 | /** 177 | * This method will return a boolean value indicating if AutoFill is enabled or not on the selected table. 178 | * 179 | * @returns boolean signifying if autofill is enables 180 | */ 181 | enabled(): boolean; 182 | } 183 | -------------------------------------------------------------------------------- /js/dataTables.autoFill.js: -------------------------------------------------------------------------------- 1 | /*! AutoFill 2.7.1 2 | * © SpryMedia Ltd - datatables.net/license 3 | */ 4 | 5 | /** 6 | * @summary AutoFill 7 | * @description Add Excel like click and drag auto-fill options to DataTables 8 | * @version 2.7.1 9 | * @author SpryMedia Ltd (www.sprymedia.co.uk) 10 | * @copyright SpryMedia Ltd. 11 | * 12 | * This source file is free software, available under the following license: 13 | * MIT license - http://datatables.net/license/mit 14 | * 15 | * This source file is distributed in the hope that it will be useful, but 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 | * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. 18 | * 19 | * For details please refer to: http://www.datatables.net 20 | */ 21 | 22 | var _instance = 0; 23 | 24 | /** 25 | * AutoFill provides Excel like auto-fill features for a DataTable 26 | * 27 | * @class AutoFill 28 | * @constructor 29 | * @param {object} oTD DataTables settings object 30 | * @param {object} oConfig Configuration object for AutoFill 31 | */ 32 | var AutoFill = function( dt, opts ) 33 | { 34 | if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.11' ) ) { 35 | throw( "Warning: AutoFill requires DataTables 1.11 or greater"); 36 | } 37 | 38 | // User and defaults configuration object 39 | this.c = $.extend( true, {}, 40 | DataTable.defaults.autoFill, 41 | AutoFill.defaults, 42 | opts 43 | ); 44 | 45 | /** 46 | * @namespace Settings object which contains customisable information for AutoFill instance 47 | */ 48 | this.s = { 49 | /** @type {DataTable.Api} DataTables' API instance */ 50 | dt: new DataTable.Api( dt ), 51 | 52 | /** @type {String} Unique namespace for events attached to the document */ 53 | namespace: '.autoFill'+(_instance++), 54 | 55 | /** @type {Object} Cached dimension information for use in the mouse move event handler */ 56 | scroll: {}, 57 | 58 | /** @type {integer} Interval object used for smooth scrolling */ 59 | scrollInterval: null, 60 | 61 | handle: { 62 | height: 0, 63 | width: 0 64 | }, 65 | 66 | /** 67 | * Enabled setting 68 | * @type {Boolean} 69 | */ 70 | enabled: false 71 | }; 72 | 73 | 74 | /** 75 | * @namespace Common and useful DOM elements for the class instance 76 | */ 77 | this.dom = { 78 | closeButton: $('
×
'), 79 | 80 | /** @type {jQuery} AutoFill handle */ 81 | handle: $('
'), 82 | 83 | /** 84 | * @type {Object} Selected cells outline - Need to use 4 elements, 85 | * otherwise the mouse over if you back into the selected rectangle 86 | * will be over that element, rather than the cells! 87 | */ 88 | select: { 89 | top: $('
'), 90 | right: $('
'), 91 | bottom: $('
'), 92 | left: $('
') 93 | }, 94 | 95 | /** @type {jQuery} Fill type chooser background */ 96 | background: $('
'), 97 | 98 | /** @type {jQuery} Fill type chooser */ 99 | list: $('
'+this.s.dt.i18n('autoFill.info', '')+'
') 100 | .attr('aria-modal', true) 101 | .attr('role', 'dialog') 102 | .append('
'), 103 | 104 | /** @type {jQuery} DataTables scrolling container */ 105 | dtScroll: null, 106 | 107 | /** @type {jQuery} Offset parent element */ 108 | offsetParent: null 109 | }; 110 | 111 | 112 | /* Constructor logic */ 113 | this._constructor(); 114 | }; 115 | 116 | 117 | 118 | $.extend( AutoFill.prototype, { 119 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 120 | * Public methods (exposed via the DataTables API below) 121 | */ 122 | enabled: function () 123 | { 124 | return this.s.enabled; 125 | }, 126 | 127 | 128 | enable: function ( flag ) 129 | { 130 | var that = this; 131 | 132 | if ( flag === false ) { 133 | return this.disable(); 134 | } 135 | 136 | this.s.enabled = true; 137 | 138 | this._focusListener(); 139 | 140 | this.dom.handle.on( 'mousedown touchstart', function (e) { 141 | that._mousedown( e ); 142 | return false; 143 | } ); 144 | 145 | $(window).on('resize', function() { 146 | var handle = $('div.dt-autofill-handle'); 147 | if(handle.length > 0 && that.dom.attachedTo !== undefined) { 148 | that._attach(that.dom.attachedTo) 149 | } 150 | }) 151 | 152 | let orientationReset = function() { 153 | that.s.handle = { 154 | height: false, 155 | width: false 156 | }; 157 | $(that.dom.handle).css({ 158 | 'height': '', 159 | 'width': '' 160 | }) 161 | if(that.dom.attachedTo !== undefined) { 162 | that._attach(that.dom.attachedTo) 163 | } 164 | } 165 | 166 | $(window) 167 | .on('orientationchange', function() { 168 | setTimeout(function() { 169 | orientationReset(); 170 | setTimeout(orientationReset, 150); 171 | }, 50); 172 | }); 173 | 174 | return this; 175 | }, 176 | 177 | disable: function () 178 | { 179 | this.s.enabled = false; 180 | 181 | this._focusListenerRemove(); 182 | 183 | return this; 184 | }, 185 | 186 | 187 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 188 | * Constructor 189 | */ 190 | 191 | /** 192 | * Initialise the RowReorder instance 193 | * 194 | * @private 195 | */ 196 | _constructor: function () 197 | { 198 | var that = this; 199 | var dt = this.s.dt; 200 | 201 | // Selectors for DataTables 1 and 2 - only one will be matched 202 | var dtScroll = $('div.dataTables_scrollBody, div.dt-scroll-body', this.s.dt.table().container()); 203 | 204 | // Make the instance accessible to the API 205 | dt.settings()[0].autoFill = this; 206 | 207 | if ( dtScroll.length ) { 208 | this.dom.dtScroll = dtScroll; 209 | 210 | // Need to scroll container to be the offset parent 211 | if ( dtScroll.css('position') === 'static' ) { 212 | dtScroll.css( 'position', 'relative' ); 213 | } 214 | } 215 | 216 | if ( this.c.enable !== false ) { 217 | this.enable(); 218 | } 219 | 220 | dt.on( 'destroy.autoFill', function () { 221 | that._focusListenerRemove(); 222 | } ); 223 | }, 224 | 225 | 226 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 227 | * Private methods 228 | */ 229 | 230 | /** 231 | * Display the AutoFill drag handle by appending it to a table cell. This 232 | * is the opposite of the _detach method. 233 | * 234 | * @param {node} node TD/TH cell to insert the handle into 235 | * @private 236 | */ 237 | _attach: function ( node ) 238 | { 239 | var dt = this.s.dt; 240 | var idx = dt.cell( node ).index(); 241 | var handle = this.dom.handle; 242 | var handleDim = this.s.handle; 243 | 244 | if ( ! idx || dt.columns( this.c.columns ).indexes().indexOf( idx.column ) === -1 ) { 245 | this._detach(); 246 | return; 247 | } 248 | 249 | if ( ! this.dom.offsetParent ) { 250 | // We attach to the table's offset parent 251 | this.dom.offsetParent = $( dt.table().node() ).offsetParent(); 252 | } 253 | 254 | if ( ! handleDim.height || ! handleDim.width ) { 255 | // Append to document so we can get its size. Not expecting it to 256 | // change during the life time of the page 257 | handle.appendTo( 'body' ); 258 | handleDim.height = handle.outerHeight(); 259 | handleDim.width = handle.outerWidth(); 260 | } 261 | 262 | // Might need to go through multiple offset parents 263 | var offset = this._getPosition( node, this.dom.offsetParent ); 264 | 265 | this.dom.attachedTo = node; 266 | handle 267 | .css( { 268 | top: offset.top + node.offsetHeight - handleDim.height, 269 | left: offset.left + node.offsetWidth - handleDim.width 270 | } ) 271 | .appendTo( this.dom.offsetParent ); 272 | }, 273 | 274 | 275 | /** 276 | * Determine can the fill type should be. This can be automatic, or ask the 277 | * end user. 278 | * 279 | * @param {array} cells Information about the selected cells from the key 280 | * up function 281 | * @private 282 | */ 283 | _actionSelector: function ( cells ) 284 | { 285 | var that = this; 286 | var dt = this.s.dt; 287 | var actions = AutoFill.actions; 288 | var available = []; 289 | 290 | // "Ask" each plug-in if it wants to handle this data 291 | $.each( actions, function ( key, action ) { 292 | if ( action.available( dt, cells ) ) { 293 | available.push( key ); 294 | } 295 | } ); 296 | 297 | if ( available.length === 1 && this.c.alwaysAsk === false ) { 298 | // Only one action available - enact it immediately 299 | var result = actions[ available[0] ].execute( dt, cells ); 300 | this._update( result, cells ); 301 | } 302 | else if ( available.length > 1 || this.c.alwaysAsk ) { 303 | // Multiple actions available - ask the end user what they want to do 304 | var list = this.dom.list.children('div.dt-autofill-list-items').empty(); 305 | 306 | // Add a cancel option 307 | available.push( 'cancel' ); 308 | 309 | $.each( available, function ( i, name ) { 310 | list.append( $('