autograph
Version:
A visual data routing automation tool.
137 lines (97 loc) • 5.33 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: ComponentLibrary.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: ComponentLibrary.js</h1>
<section>
<article>
<pre class="prettyprint source"><code>/**
* @module ComponentLibrary
*/
define(['jquery', 'components/models/BaseComponent', 'components/views/BaseComponentView', 'components/views/WebviewComponentView'],
function($, BaseComponent, BaseComponentView, WebviewComponentView){
/**
* Manage available components.
* @class ComponentLibrary
*/
return function(container, components, componentPath, selectCallback) {
var self = this;
self.componentList = container.append("div").attr("class", "component-list");
d3.json(componentPath+components, function (components) {
for (var i = 0, l = components.length; i < l; i++) {
var componentDescription = components[i];
self.componentList.append("div")
.attr("class", "component-option")
.attr("id", componentDescription.name)
.datum(componentDescription)
.text(componentDescription.name);
}
d3.selectAll(".component-option").on("click", function() {
selectCallback(d3.select(d3.event.target).datum());
});
});
var classRegistry = {};
function getClass(className, path, callback) {
if (classRegistry[className]) {
callback(classRegistry[className]);
}
else {
$.get(path, function (str) {
eval(str);
classRegistry[className] = eval(className);
callback(classRegistry[className]);
});
}
}
/**
* @method
* @param componentDescription
* @param callback
*/
self.loadComponentClasses = function(componentDescription, callback) {
var modelClass = componentDescription.model;
var viewClass = componentDescription.view;
var fullpath = componentDescription.path || "src/components/";
var result = {};
getClass(modelClass, componentPath + fullpath + "models/" + modelClass + ".js?v=" + Math.random(), function (mc) {
result.modelClass = mc;
if (viewClass) {
getClass(viewClass, componentPath + fullpath + "views/" + viewClass + ".js?v=" + Math.random(), function (vc) {
result.viewClass = vc;
callback(result);
});
}
else {
result.viewClass = BaseComponentView;
callback(result);
}
});
};
};
});
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-autograph.html">autograph</a></li><li><a href="module-BaseComponent.html">BaseComponent</a></li><li><a href="module-BaseComponentView.html">BaseComponentView</a></li><li><a href="module-ComponentCollection.html">ComponentCollection</a></li><li><a href="module-ComponentLibrary.html">ComponentLibrary</a></li><li><a href="module-CursorModel.html">CursorModel</a></li><li><a href="TerminalModel_.html">models/TerminalModel</a></li><li><a href="module-PositionedModel.html">PositionedModel</a></li><li><a href="module-SelectionTool.html">SelectionTool</a></li><li><a href="module-TerminalModel.html">TerminalModel</a></li><li><a href="module-WebviewComponentView.html">WebviewComponentView</a></li><li><a href="module-WireModel.html">WireModel</a></li></ul><h3>Classes</h3><ul><li><a href="BaseComponentView.html">BaseComponentView</a></li><li><a href="ButtonComponent.html">ButtonComponent</a></li><li><a href="ButtonComponentView.html">ButtonComponentView</a></li><li><a href="ClockComponent.html">ClockComponent</a></li><li><a href="ComponentLibrary.html">ComponentLibrary</a></li><li><a href="DelayComponent.html">DelayComponent</a></li><li><a href="EchoComponentView.html">EchoComponentView</a></li><li><a href="HTTPClientComponentView.html">HTTPClientComponentView</a></li><li><a href="TerminalModel.html">models/TerminalModel</a></li><li><a href="PositionedModel.html">PositionedModel</a></li><li><a href="TerminalModel__.html">TerminalModel</a></li><li><a href="ValueComponentView.html">ValueComponentView</a></li><li><a href="WebviewComponentView.html">WebviewComponentView</a></li><li><a href="WireModel.html">WireModel</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addContent">addContent</a></li><li><a href="global.html#hilight">hilight</a></li><li><a href="global.html#initialize">initialize</a></li><li><a href="global.html#render">render</a></li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Wed May 07 2014 22:03:07 GMT-0500 (CDT)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>