Module pattern is now implemented via templating

Previously two modules were defined, Layout.js, which is the internal implementation, and main.js, which depended on Layout.js and performed the fill / extract functionality required for a public JavaScript API.

This simplifies the implementation by just exposing a single UMD module by directly including Layout.js within the module wrapper.

Fixes #103
This commit is contained in:
Colin Eberhardt
2015-08-11 17:21:09 +01:00
parent 401f473449
commit 3b406b30c2
3 changed files with 17 additions and 14 deletions

25
src/css-layout.js Normal file
View File

@@ -0,0 +1,25 @@
// UMD (Universal Module Definition)
// See https://github.com/umdjs/umd for reference
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.computeLayout = factory();
}
}(this, function () {
// @@include('./Layout.js')
return function(node) {
node = computeLayout.fillNodes(node);
computeLayout.computeLayout(node);
node = computeLayout.extractNodes(node);
return node;
};
}));