diff --git a/js/bootstrap-timepicker.js b/js/bootstrap-timepicker.js index bbb923c5..7691b979 100644 --- a/js/bootstrap-timepicker.js +++ b/js/bootstrap-timepicker.js @@ -8,7 +8,39 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -(function($, window, document) { +(function (factory) { + if (typeof define === 'function' && define.amd) { + define('window', function() { + return window; + }); + + define('document', function() { + return document; + }); + // AMD. Register as an anonymous module. + define(['jquery', 'window', 'document'], factory); + } else if (typeof module === 'object' && module.exports) { + // Node/CommonJS + module.exports = function(root, jQuery, window, document) { + if (jQuery === undefined) { + // require('jQuery') returns a factory that requires window to + // build a jQuery instance, we normalize how we use modules + // that require this pattern but the window provided is a noop + // if it's defined (how jquery works) + if (typeof window !== 'undefined') { + jQuery = require('jquery'); + } else { + jQuery = require('jquery')(root); + } + } + factory(jQuery, window, document); + return jQuery; + }; + } else { + // Browser globals + factory(jQuery, window, document); + } +}(function($, window, document) { 'use strict'; // TIMEPICKER PUBLIC CLASS DEFINITION @@ -1174,4 +1206,4 @@ } ); -})(jQuery, window, document); +}));