index.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <html>
  2. <head>
  3. <title>bpmn-js modeler demo</title>
  4. <link rel="stylesheet" href="css/diagram-js.css" />
  5. <link rel="stylesheet" href="vendor/bpmn-font/css/bpmn-embedded.css" />
  6. <link rel="stylesheet" href="css/app.css" />
  7. </head>
  8. <body>
  9. <div class="content" id="js-drop-zone">
  10. <div class="message intro">
  11. <div class="note">
  12. Drop BPMN diagram from your desktop or <a id="js-create-diagram" href>create a new diagram</a> to get started.
  13. </div>
  14. </div>
  15. <div class="message error">
  16. <div class="note">
  17. <p>Ooops, we could not display the BPMN 2.0 diagram.</p>
  18. <div class="details">
  19. <span>cause of the problem</span>
  20. <pre></pre>
  21. </div>
  22. </div>
  23. </div>
  24. <div class="canvas" id="js-canvas"></div>
  25. <div id="js-properties-panel"></div>
  26. </div>
  27. <ul class="buttons">
  28. <li>
  29. download
  30. </li>
  31. <li>
  32. <a id="js-download-diagram" href title="download BPMN diagram">
  33. BPMN diagram
  34. </a>
  35. </li>
  36. <li>
  37. <a id="js-download-svg" href title="download as SVG image">
  38. SVG image
  39. </a>
  40. </li>
  41. </ul>
  42. <script src="index.js"></script>
  43. <script>
  44. var bpmnJS = new BpmnJS({
  45. container:$('#js-drop-zone'),
  46. canvas:$('#js-canvas'),
  47. propertiesPanel: $('#js-properties-panel')
  48. });
  49. //var container = $('#js-drop-zone');
  50. // function openDiagram(xml) {
  51. // renderer.importXML(xml, function(err) {
  52. // if (err) {
  53. // container
  54. // .removeClass('with-diagram')
  55. // .addClass('with-error');
  56. // container.find('.error pre').text(err.message);
  57. // console.error(err);
  58. // } else {
  59. // container
  60. // .removeClass('with-error')
  61. // .addClass('with-diagram');
  62. // }
  63. // });
  64. // }
  65. // function createNewDiagram() {
  66. // openDiagram(newDiagramXML);
  67. // }
  68. $('#js-create-diagram').click(function(e) {
  69. e.stopPropagation();
  70. e.preventDefault();
  71. bpmnJS.createNewDiagram();
  72. });
  73. function setEncoded(link, name, data) {
  74. var encodedData = encodeURIComponent(data);
  75. if (data) {
  76. link.addClass('active').attr({
  77. 'href': 'data:application/bpmn20-xml;charset=UTF-8,' + encodedData,
  78. 'download': name
  79. });
  80. } else {
  81. link.removeClass('active');
  82. }
  83. }
  84. $('#js-download-diagram').click(function(e) {
  85. e.stopPropagation();
  86. e.preventDefault();
  87. bpmnJS.saveDiagram(function(err, xml) {
  88. setEncoded($('#js-download-diagram'), 'diagram.bpmn', err ? null : xml);
  89. });
  90. })
  91. if (!window.FileList || !window.FileReader) {
  92. window.alert(
  93. 'Looks like you use an older browser that does not support drag and drop. ' +
  94. 'Try using Chrome, Firefox or the Internet Explorer > 10.');
  95. } else {
  96. bpmnJS.registerFileDrop($('#js-drop-zone'), bpmnJS.openDiagram);
  97. }
  98. </script>
  99. </html>