Skip to content

Commit 12f6525

Browse files
committed
Added AMD/CommonJS support.
1 parent 5f9d158 commit 12f6525

File tree

3 files changed

+60
-49
lines changed

3 files changed

+60
-49
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ src=`append_file "$src" src/selectize.js`
2222
# format and wrap...
2323

2424
src=`echo -e "$src" | while read -r line; do echo -e "\t$line"; done`
25-
src="$banner\n\n(function ($,window,document) {\n\t\"use strict\";$src\n})(jQuery,window,document);"
2625
26+
src="$banner\n\n(function (factory) {\n\tif (typeof exports === 'object') {\n\t\tfactory(require('jquery'));\n\t} else if (typeof define === 'function' && define.amd) {\n\t\tdefine(['jquery'], factory);\n\t} else {\n\t\tfactory(jQuery);\n\t}\n}(function ($) {\n\t\"use strict\";$src\n\n\treturn Selectize;\n\n}));"
2727
echo -e "$src" > $out
2828
printf " done.\n"
2929

selectize.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
/*! selectize.js | https://github.com/brianreavis/jquery-selectize | Apache License (v2) */
22

3-
(function ($,window,document) {
3+
(function (factory) {
4+
if (typeof exports === 'object') {
5+
factory(require('jquery'));
6+
} else if (typeof define === 'function' && define.amd) {
7+
define(['jquery'], factory);
8+
} else {
9+
factory(jQuery);
10+
}
11+
}(function ($) {
412
"use strict";
513

614
// --- src/contrib/highlight.js ---
@@ -1777,4 +1785,7 @@
17771785

17781786
return html;
17791787
};
1780-
})(jQuery,window,document);
1788+
1789+
return Selectize;
1790+
1791+
}));

0 commit comments

Comments
 (0)