show.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. var diagramXML;
  2. function setXml(xml){
  3. if(xml != null||xml != ''){
  4. diagramXML = xml;
  5. }else{
  6. diagramXML = '<?xml version="1.0" encoding="UTF-8"?><definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://www.omg.org/spec/BPMN/2.0/20100501/BPMN20.xsd"><process id="Process_18p4xqa" /><bpmndi:BPMNDiagram id="sid-74620812-92c4-44e5-949c-aa47393d3830"><bpmndi:BPMNPlane id="sid-cdcae759-2af7-4a6d-bd02-53f3352a731d" bpmnElement="Process_18p4xqa" /><bpmndi:BPMNLabelStyle id="sid-e0502d32-f8d1-41cf-9c4a-cbb49fecf581"><omgdc:Font name="Arial" size="11" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" /></bpmndi:BPMNLabelStyle><bpmndi:BPMNLabelStyle id="sid-84cb49fd-2f7c-44fb-8950-83c3fa153d3b"><omgdc:Font name="Arial" size="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" /></bpmndi:BPMNLabelStyle></bpmndi:BPMNDiagram></definitions>';
  7. }
  8. $("#show-button").trigger("click");
  9. }
  10. $(document).ready(function(){
  11. if(id!=''&&id!='null')
  12. show();
  13. });
  14. function show(){
  15. $.ajax({
  16. url : basePath + 'WFP?module=definition&action=getXml&id='+ id,
  17. type : 'POST',
  18. data : {
  19. },
  20. success : function(json) {
  21. var obj = JSON.parse(json);
  22. if(obj != null && obj != ''){
  23. var xmlData = obj.xmlData;
  24. diagramXML = xmlData;
  25. }else{
  26. var url = basePath + 'player/page/lc404.jsp';
  27. $("#bpmnShow", parent.document).attr('src',url);
  28. }
  29. $("#show-button").trigger("click");
  30. }
  31. });
  32. }
  33. (function(BpmnViewer, $) {
  34. // create viewer
  35. var bpmnViewer = new BpmnViewer({
  36. container: '#canvas'
  37. });
  38. var canvas = bpmnViewer.get('canvas'),
  39. overlays = bpmnViewer.get('overlays');
  40. // import function
  41. function importXML(xml) {
  42. // import diagram
  43. bpmnViewer.importXML(xml, function(err) {
  44. // if (err) {
  45. // return console.error('could not import BPMN 2.0 diagram', err);
  46. // }
  47. canvas.zoom('fit-viewport');
  48. });
  49. }
  50. var showButton = document.querySelector('#show-button');
  51. showButton.addEventListener('click', function() {
  52. importXML(diagramXML);
  53. })
  54. })(window.BpmnJS, window.jQuery);