Rendering: UMD loader for datetime formatter

pull/295/head
Allan Jardine 8 years ago
parent cf2b89baef
commit 89cc3a6280

@ -59,7 +59,42 @@
* } );
*/
jQuery.fn.dataTable.render.moment = function ( from, to, locale ) {
// UMD
(function( factory ) {
"use strict";
if ( typeof define === 'function' && define.amd ) {
// AMD
define( ['jquery'], function ( $ ) {
return factory( $, window, document );
} );
}
else if ( typeof exports === 'object' ) {
// CommonJS
module.exports = function (root, $) {
if ( ! root ) {
root = window;
}
if ( ! $ ) {
$ = typeof window !== 'undefined' ?
require('jquery') :
require('jquery')( root );
}
return factory( $, root, root.document );
};
}
else {
// Browser
factory( jQuery, window, document );
}
}
(function( $, window, document ) {
$.fn.dataTable.render.moment = function ( from, to, locale ) {
// Argument shifting
if ( arguments.length === 1 ) {
locale = 'en';
@ -78,3 +113,6 @@ jQuery.fn.dataTable.render.moment = function ( from, to, locale ) {
return m.format( type === 'sort' || type === 'type' ? 'x' : to );
};
};
}));

Loading…
Cancel
Save