Merge pull request #984 from aindlq/common-js

Add support for commonjs.
This commit is contained in:
Ian Gilman 2016-07-27 09:53:43 -07:00 committed by GitHub
commit 0b8aca750f
2 changed files with 20 additions and 11 deletions

View File

@ -10,6 +10,7 @@
"globals": { "globals": {
"OpenSeadragon": true, "OpenSeadragon": true,
"define": false "define": false,
"module": false
} }
} }

View File

@ -685,19 +685,10 @@
* @param {OpenSeadragon.Options} options - Viewer options. * @param {OpenSeadragon.Options} options - Viewer options.
* @returns {OpenSeadragon.Viewer} * @returns {OpenSeadragon.Viewer}
*/ */
window.OpenSeadragon = window.OpenSeadragon || function( options ){ function OpenSeadragon( options ){
return new OpenSeadragon.Viewer( options ); return new OpenSeadragon.Viewer( options );
};
if (typeof define === 'function' && define.amd) {
define(function () {
return (window.OpenSeadragon);
});
} }
(function( $ ){ (function( $ ){
@ -2596,3 +2587,20 @@ if (typeof define === 'function' && define.amd) {
} }
}(OpenSeadragon)); }(OpenSeadragon));
// Universal Module Definition, supports CommonJS, AMD and simple script tag
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// expose as amd module
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// expose as commonjs module
module.exports = factory();
} else {
// expose as window.OpenSeadragon
root.OpenSeadragon = factory();
}
}(this, function () {
return OpenSeadragon;
}));