summaryrefslogtreecommitdiffstats
path: root/awesomplete.js
diff options
context:
space:
mode:
Diffstat (limited to 'awesomplete.js')
-rw-r--r--awesomplete.js35
1 files changed, 26 insertions, 9 deletions
diff --git a/awesomplete.js b/awesomplete.js
index 442bfd1..4053101 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
@@ -184,6 +184,8 @@ _.prototype = {
lis[i].setAttribute("aria-selected", "true");
this.status.textContent = lis[i].textContent;
}
+
+ $.fire(this.input, "awesomplete-highlight");
},
select: function (selected) {
@@ -356,16 +358,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 _;
+
+}());