bpmn-js/example/index.html

79 lines
1.9 KiB
HTML
Raw Normal View History

<html>
<head>
<title>bpmn-js demo</title>
<link rel="stylesheet" href="style.css" />
<style>
#drop-zone {
width: 200px;
line-height: 100px;
background: fuchsia;
color: #FFF;
font-size: 20px;
text-align: center;
}
</style>
</head>
<body>
<div id="drop-zone">Drop BPMN here</div>
<output id="list"></output>
<div id="canvas"></div>
<script src="../bpmn.js"></script>
<script>
var bpmn = require('bpmn');
var Model = require('bpmn/Model');
var Diagram = require('bpmn/Diagram');
</script>
<script>
var diagram = new Diagram(document.getElementById('canvas'));
function handleFileSelect(evt) {
evt.stopPropagation();
evt.preventDefault();
var files = evt.dataTransfer.files; // FileList object.
// files is a FileList of File objects. List some properties.
for (var i = 0, f; f = files[i]; i++) {
var reader = new FileReader();
reader.onload = function(e) {
var xml = e.target.result;
Model.fromXML(xml, 'bpmn:Definitions', function(err, definitions) {
if (err) {
console.error(err);
} else {
diagram.importDefinitions(definitions, function() {
console.log("import done!!");
});
}
});
/*renderer.renderXML(xml, function(err) {
console.log('diagram rendererd');
});*/
};
reader.readAsText(f);
}
}
function handleDragOver(evt) {
evt.stopPropagation();
evt.preventDefault();
evt.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}
// Setup the dnd listeners.
var dropZone = document.getElementById('drop-zone');
dropZone.addEventListener('dragover', handleDragOver, false);
dropZone.addEventListener('drop', handleFileSelect, false);
</script>
</html>