2014-03-18 16:01:24 +00:00
|
|
|
var Diagram = require('diagram-js');
|
|
|
|
var Importer = require('./Importer');
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
function Viewer(container) {
|
2014-03-18 16:01:24 +00:00
|
|
|
this.container = container;
|
|
|
|
}
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
Viewer.prototype.importDefinitions = function(definitions, done) {
|
2014-03-18 16:01:24 +00:00
|
|
|
|
|
|
|
if (this.diagram) {
|
|
|
|
this.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.diagram = this.createDiagram();
|
|
|
|
this.definitions = definitions;
|
|
|
|
|
|
|
|
Importer.importBpmnDiagram(this.diagram, definitions, done);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
Viewer.prototype.exportDefinitions = function(done) {
|
2014-03-18 16:01:24 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
Viewer.prototype.createDiagram = function() {
|
2014-03-18 16:01:24 +00:00
|
|
|
return new Diagram({ canvas: { container: this.container }});
|
|
|
|
};
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
Viewer.prototype.clear = function() {
|
2014-03-18 16:01:24 +00:00
|
|
|
this.container.innerHTML = '';
|
|
|
|
};
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
module.exports = Viewer;
|