datatables.net-feature-conditionalpaging 1.0.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 ADDED
@@ -0,0 +1,24 @@
1
+
2
+ # DataTables deep linking
3
+
4
+ Shows or hides the paging control depending on the amount of data in the table.
5
+
6
+
7
+ ## Usage
8
+
9
+ To install with npm (substitute with your favorite package manager if you prefer):
10
+
11
+ ```
12
+ npm install datatables.net datatables.net-feature-conditionalpaging
13
+ ```
14
+
15
+ Then in your Javascript file (assuming you are using ES Modules):
16
+
17
+ ```js
18
+ import DataTable from 'datatables.net';
19
+ import 'datatables.net-feature-conditionalpaging';
20
+
21
+ new DataTable('#example', {
22
+ conditionalPaging: true
23
+ });
24
+ ```
File without changes
@@ -0,0 +1,10 @@
1
+ /*! © SpryMedia Ltd, Matthew Hasbach - datatables.net/license */
2
+ declare module 'datatables.net' {
3
+ interface Config {
4
+ conditionalPaging: boolean;
5
+ }
6
+ interface Defaults {
7
+ conditionalPaging: boolean;
8
+ }
9
+ }
10
+ export {};
@@ -0,0 +1,78 @@
1
+ /*! © SpryMedia Ltd, Matthew Hasbach - datatables.net/license - 3.0.0-beta.2 */
2
+
3
+ (function(factory){
4
+ if (typeof define === 'function' && define.amd) {
5
+ // AMD
6
+ define(['datatables.net'], function (dt) {
7
+ return factory(window, document, dt);
8
+ });
9
+ }
10
+ else if (typeof exports === 'object') {
11
+ // CommonJS
12
+ var cjsRequires = function (root) {
13
+ if (! root.DataTable) {
14
+ require('datatables.net')(root);
15
+ }
16
+ };
17
+
18
+ if (typeof window === 'undefined') {
19
+ module.exports = function (root) {
20
+ if (! root) {
21
+ // CommonJS environments without a window global must pass a
22
+ // root. This will give an error otherwise
23
+ root = window;
24
+ }
25
+
26
+ cjsRequires(root);
27
+ return factory(root, root.document, root.DataTable);
28
+ };
29
+ }
30
+ else {
31
+ cjsRequires(window);
32
+ module.exports = factory(window, window.document, window.DataTable);
33
+ }
34
+ }
35
+ else {
36
+ // Browser
37
+ factory(window, document, window.DataTable);
38
+ }
39
+ }(function(window, document, DataTable) {
40
+ 'use strict';
41
+
42
+ var Dom = DataTable.Dom;
43
+ var util = DataTable.util;
44
+
45
+ /**
46
+ * @summary ConditionalPaging
47
+ * @description Hide paging controls when the amount of pages is <= 1
48
+ * @author Matthew Hasbach (https://github.com/mjhasbach)
49
+ * @copyright Copyright Matthew Hasbach and SpryMedia
50
+ * @license MIT - http://datatables.net/license/mit
51
+ *
52
+ * This feature plugin for DataTables hides paging controls when the amount
53
+ * of pages is <= 1.
54
+ *
55
+ * @example
56
+ * new DataTable('#myTable', {
57
+ * conditionalPaging: true
58
+ * });
59
+ */
60
+ Dom.s(document).on('init.dt', function (e, dtSettings) {
61
+ if (e.namespace !== 'dt') {
62
+ return;
63
+ }
64
+ var options = dtSettings.init.conditionalPaging ||
65
+ DataTable.defaults.conditionalPaging;
66
+ if (util.is.plainObject(options) || options === true) {
67
+ var config = util.is.plainObject(options) ? options : {}, api = new DataTable.Api(dtSettings), conditionalPaging = function (e) {
68
+ var paging = Dom.s(api.table().container()).find('div.dt-paging'), pages = api.page.info().pages;
69
+ paging.css('visibility', pages <= 1 ? 'hidden' : '');
70
+ };
71
+ conditionalPaging(null);
72
+ api.on('draw.dt', conditionalPaging);
73
+ }
74
+ });
75
+
76
+
77
+ return DataTable;
78
+ }));
@@ -0,0 +1,2 @@
1
+ /*! © SpryMedia Ltd, Matthew Hasbach - datatables.net/license - 3.0.0-beta.2 */
2
+ (i=>{var t;"function"==typeof define&&define.amd?define(["datatables.net"],function(n){return i(window,document,n)}):"object"==typeof exports?(t=function(n){n.DataTable||require("datatables.net")(n)},"undefined"==typeof window?module.exports=function(n){return n=n||window,t(n),i(0,n.document,n.DataTable)}:(t(window),module.exports=i(window,window.document,window.DataTable))):i(window,document,window.DataTable)})(function(n,i,t){var a=t.Dom,o=t.util;return a.s(i).on("init.dt",function(n,i){var e;"dt"===n.namespace&&(n=i.init.conditionalPaging||t.defaults.conditionalPaging,o.is.plainObject(n)||!0===n)&&(o.is.plainObject(n),e=new t.Api(i),(n=function(n){var i=a.s(e.table().container()).find("div.dt-paging"),t=e.page.info().pages;i.css("visibility",t<=1?"hidden":"")})(),e.on("draw.dt",n))}),t});
@@ -0,0 +1,2 @@
1
+ /*! © SpryMedia Ltd, Matthew Hasbach - datatables.net/license - 3.0.0-beta.2 */
2
+ import DataTable,{Dom,util}from"datatables.net";Dom.s(document).on("init.dt",function(a,i){var n;"dt"===a.namespace&&(a=i.init.conditionalPaging||DataTable.defaults.conditionalPaging,util.is.plainObject(a)||!0===a)&&(util.is.plainObject(a),n=new DataTable.Api(i),(a=function(a){var i=Dom.s(n.table().container()).find("div.dt-paging"),t=n.page.info().pages;i.css("visibility",t<=1?"hidden":"")})(),n.on("draw.dt",a))});export default DataTable;
@@ -0,0 +1,38 @@
1
+ /*! © SpryMedia Ltd, Matthew Hasbach - datatables.net/license - 3.0.0-beta.2 */
2
+
3
+ import DataTable, { Dom, util } from 'datatables.net';
4
+
5
+ /**
6
+ * @summary ConditionalPaging
7
+ * @description Hide paging controls when the amount of pages is <= 1
8
+ * @author Matthew Hasbach (https://github.com/mjhasbach)
9
+ * @copyright Copyright Matthew Hasbach and SpryMedia
10
+ * @license MIT - http://datatables.net/license/mit
11
+ *
12
+ * This feature plugin for DataTables hides paging controls when the amount
13
+ * of pages is <= 1.
14
+ *
15
+ * @example
16
+ * new DataTable('#myTable', {
17
+ * conditionalPaging: true
18
+ * });
19
+ */
20
+ Dom.s(document).on('init.dt', function (e, dtSettings) {
21
+ if (e.namespace !== 'dt') {
22
+ return;
23
+ }
24
+ var options = dtSettings.init.conditionalPaging ||
25
+ DataTable.defaults.conditionalPaging;
26
+ if (util.is.plainObject(options) || options === true) {
27
+ var config = util.is.plainObject(options) ? options : {}, api = new DataTable.Api(dtSettings), conditionalPaging = function (e) {
28
+ var paging = Dom.s(api.table().container()).find('div.dt-paging'), pages = api.page.info().pages;
29
+ paging.css('visibility', pages <= 1 ? 'hidden' : '');
30
+ };
31
+ conditionalPaging(null);
32
+ api.on('draw.dt', conditionalPaging);
33
+ }
34
+ });
35
+
36
+
37
+ export default DataTable;
38
+
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "datatables.net-feature-conditionalpaging",
3
+ "version": "1.0.0",
4
+ "description": "DataTables plugin: Conditionally show the paging control",
5
+ "main": "dist/dataTables.conditionalPaging.js",
6
+ "module": "dist/dataTables.conditionalPaging.mjs",
7
+ "types": "dist/dataTables.conditionalPaging.d.ts",
8
+ "files": [
9
+ "dist/*.css",
10
+ "dist/*.js",
11
+ "dist/*.mjs",
12
+ "dist/*.d.ts"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/DataTables/Plugins.git"
17
+ },
18
+ "keywords": [
19
+ "DataTables",
20
+ "plugins"
21
+ ],
22
+ "author": "SpryMedia Ltd",
23
+ "license": "MIT",
24
+ "bugs": {
25
+ "url": "https://datatables.net/forums"
26
+ },
27
+ "homepage": "https://datatables.net",
28
+ "dependencies": {
29
+ "datatables.net": "^3.0.0-0"
30
+ }
31
+ }