Make SwaggerUi UMD compatible

This commit is contained in:
Mohsen Azimi
2015-03-23 14:22:12 -07:00
parent 440b62a2b2
commit 93c18d59b8
14 changed files with 197 additions and 127 deletions

View File

@@ -1,6 +1,6 @@
'use strict';
window.SwaggerUi = Backbone.Router.extend({
var SwaggerUi = Backbone.Router.extend({
dom_id: 'swagger_ui',
@@ -195,6 +195,7 @@ window.SwaggerUi = Backbone.Router.extend({
});
window.SwaggerUi = SwaggerUi;
window.SwaggerUi.Views = {};
// don't break backward compatibility with previous versions and warn users to upgrade their code
@@ -228,4 +229,25 @@ window.SwaggerUi.Views = {};
console.warn(message);
}
}
})();
})();
// UMD
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['b'], function (b) {
return (root.SwaggerUi = factory(b));
});
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// like Node.
module.exports = factory(require('b'));
} else {
// Browser globals
root.SwaggerUi = factory(root.b);
}
}(this, function () {
return SwaggerUi;
}));