diff options
Diffstat (limited to 'awesomplete.js')
-rw-r--r-- | awesomplete.js | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/awesomplete.js b/awesomplete.js index 5713d2e..bb93afa 100644 --- a/awesomplete.js +++ b/awesomplete.js @@ -7,7 +7,7 @@ (function () { -var _ = self.Awesomplete = function (input, o) { +var _ = function (input, o) { var me = this; // Setup @@ -350,16 +350,31 @@ function init() { }); } -// DOM already loaded? -if (document.readyState !== "loading") { - init(); -} -else { - // Wait for it - document.addEventListener("DOMContentLoaded", init); +// Are we in a browser? Check for Document constructor +if (typeof Document !== 'undefined') { + // DOM already loaded? + if (document.readyState !== "loading") { + init(); + } + else { + // Wait for it + document.addEventListener("DOMContentLoaded", init); + } } _.$ = $; _.$$ = $$; -})(); +// Make sure to export Awesomplete on self when in a browser +if (typeof self !== 'undefined') { + self.Awesomplete = _; +} + +// Expose Awesomplete as a CJS module +if (typeof exports === 'object') { + module.exports = _; +} + +return _; + +}()); |