Skip to content

Commit d7aeaa4

Browse files
committed
Fix #22: Update AMD and CommonJS require names to use datatables.net
1 parent f9c6f16 commit d7aeaa4

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

js/dataTables.checkboxes.js

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,48 @@
1-
/*! Checkboxes 1.1.1
1+
/*! Checkboxes 1.1.2
22
* Copyright (c) Gyrocode (www.gyrocode.com)
33
* License: MIT License
44
*/
55

66
/**
77
* @summary Checkboxes
88
* @description Checkboxes extension for jQuery DataTables
9-
* @version 1.1.1
9+
* @version 1.1.2
1010
* @file dataTables.checkboxes.js
1111
* @author Gyrocode (http://www.gyrocode.com/projects/jquery-datatables-checkboxes/)
1212
* @contact http://www.gyrocode.com/contacts
1313
* @copyright Copyright (c) Gyrocode
1414
* @license MIT License
1515
*/
1616

17-
(function(window, document, undefined) {
17+
(function( factory ){
18+
if ( typeof define === 'function' && define.amd ) {
19+
// AMD
20+
define( ['jquery', 'datatables.net'], function ( $ ) {
21+
return factory( $, window, document );
22+
} );
23+
}
24+
else if ( typeof exports === 'object' ) {
25+
// CommonJS
26+
module.exports = function (root, $) {
27+
if ( ! root ) {
28+
root = window;
29+
}
1830

31+
if ( ! $ || ! $.fn.dataTable ) {
32+
$ = require('datatables.net')(root, $).$;
33+
}
1934

20-
var factory = function( $, DataTable ) {
21-
"use strict";
35+
return factory( $, root, root.document );
36+
};
37+
}
38+
else {
39+
// Browser
40+
factory( jQuery, window, document );
41+
}
42+
}(function( $, window, document, undefined ) {
43+
'use strict';
44+
var DataTable = $.fn.dataTable;
45+
2246

2347
/**
2448
* Checkboxes is an extension for the jQuery DataTables library that provides
@@ -811,22 +835,6 @@ $(document).on( 'preInit.dt.dtr', function (e, settings, json) {
811835
new Checkboxes( settings );
812836
} );
813837

814-
return Checkboxes;
815-
}; // /factory
816-
817-
818-
// Define as an AMD module if possible
819-
if ( typeof define === 'function' && define.amd ) {
820-
define( ['jquery', 'datatables'], factory );
821-
}
822-
else if ( typeof exports === 'object' ) {
823-
// Node/CommonJS
824-
factory( require('jquery'), require('datatables') );
825-
}
826-
else if ( jQuery && !jQuery.fn.dataTable.Checkboxes ) {
827-
// Otherwise simply initialise as normal, stopping multiple evaluation
828-
factory( jQuery, jQuery.fn.dataTable );
829-
}
830838

831-
832-
})(window, document);
839+
return Checkboxes;
840+
}));

0 commit comments

Comments
 (0)