Add AMD support.

This commit is contained in:
Hyunje Alex Jun 2015-02-12 18:45:04 +00:00
parent 7a8b47179c
commit 11997131f4
3 changed files with 19 additions and 7 deletions

View File

@ -4,7 +4,8 @@
"browser": true "browser": true
}, },
"globals": { "globals": {
"$": true "$": true,
"define": true
}, },
"rules" : { "rules" : {
"quotes": false, "quotes": false,

View File

@ -5,7 +5,13 @@
var ps = require('../main'); var ps = require('../main');
window.PerfectScrollbar = ps; if (typeof define === 'function' && define.amd) {
if (typeof window.Ps === 'undefined') { // AMD
window.Ps = ps; define(ps);
} else {
// Add to a global object.
window.PerfectScrollbar = ps;
if (typeof window.Ps === 'undefined') {
window.Ps = ps;
}
} }

View File

@ -33,9 +33,14 @@ function mountJQuery(jQuery) {
}; };
} }
var jq = window.jQuery ? window.jQuery : window.$; if (typeof define === 'function' && define.amd) {
if (typeof jq !== 'undefined') { // AMD. Register as an anonymous module.
mountJQuery(jq); define(['jquery'], mountJQuery);
} else {
var jq = window.jQuery ? window.jQuery : window.$;
if (typeof jq !== 'undefined') {
mountJQuery(jq);
}
} }
module.exports = mountJQuery; module.exports = mountJQuery;