Index: Renderer.js =================================================================== --- Renderer.js (revision 10463) +++ Renderer.js (working copy) @@ -268,6 +268,14 @@ return; } + // CAM-943: IE 7 + if (typeof String.prototype.trim !== 'function') { + // console.warn("defining String.trim()"); + String.prototype.trim = function() { + return this.replace(/^\s+|\s+$/g, ''); + } + } + var text = text.replace(/ /g, "").replace(/ /g, "").replace(/\n/g, ""); var textLines = []; // the lines which will be used to render Index: Transformer.js =================================================================== --- Transformer.js (revision 10463) +++ Transformer.js (working copy) @@ -44,8 +44,53 @@ Transformer.prototype.transform = function(source) { + // CAM-943: IE 7 - begin + function getElementsByTagNameNS(elt, ns, name) { + if (elt.getElementsByTagNameNS) { + // console.debug("using getElementsByTagNameNS"); + return elt.getElementsByTagNameNS(ns, name); + } // else: fallback to getElementsByTagName (IE prior to version 9) + // console.debug("using getElementsByTagName instead of getElementsByTagNameNS"); + // TODO: use namespace mapping of XML document + if (ns == NS_BPMN_DIAGRAM_INTERCHANGE) { name = "bpmndi:" + name; } + return elt.getElementsByTagName(name); + } + + function getLocalName(elt) { + if (elt.localName) { + return elt.localName; + } + var name = elt.nodeName; + if (name != null) { + name = name.replace(/[^:]*:/, ""); // strip "namespace:" + } + // console.debug("nodeName=" + elt.nodeName + ", localName=" + name); + return name; + } + + function getTextContent(elt) { + if (elt.textContent) { + return elt.textContent; + } + return elt.text; + } + + function getArrayIndexOf(array, element) { + if (array.indexOf) { + return array.indexOf(element); + } + var n = array.length; + for (var i = 0; i < n; i++) { + if (array[i] == element) { + return i; // found + } + } + return -1; // not found + } + // CAM-943: IE 7 - end + var doc = getXmlObject(source); - var definitions = doc.getElementsByTagNameNS(NS_BPMN_SEMANTIC, "definitions"); + var definitions = getElementsByTagNameNS(doc, NS_BPMN_SEMANTIC, "definitions"); if(definitions.length == 0) { throw "A BPMN 2.0 XML file must contain at least one definitions element"; @@ -68,7 +113,7 @@ var attributes = element.attributes; // set the type - bpmnObject.type = element.localName; + bpmnObject.type = getLocalName(element); // copy all attributes from the xml element to the json object for(var i = 0; attributes != null && i < attributes.length; i++) { @@ -149,7 +194,7 @@ bpmnObject.outgoing.push(outgoingFlows[i].id); } - if(!!bpmnObject.default && isExecutable) { + if(!!bpmnObject["default"] && isExecutable) { var conditionalFlowFound = false; @@ -168,7 +213,7 @@ } if(!conditionalFlowFound) { - throw "Activity with id '"+bpmnObject.id+"' declares default flow with id '" + bpmnObject.default + "' but has no conditional flows."; + throw "Activity with id '"+bpmnObject.id+"' declares default flow with id '" + bpmnObject["default"] + "' but has no conditional flows."; } } } @@ -259,10 +304,10 @@ } // extract conditions: - var conditions = element.getElementsByTagNameNS(NS_BPMN_SEMANTIC, "conditionExpression"); + var conditions = getElementsByTagNameNS(element, NS_BPMN_SEMANTIC, "conditionExpression"); if(!!conditions && conditions.length >0) { var condition = conditions[0]; - sequenceFlow.condition = condition.textContent; + sequenceFlow.condition = getTextContent(condition); } sequenceFlow.properties = {}; @@ -283,7 +328,7 @@ } do { - if(element.nodeName == "sequenceFlow" || element.localName == "sequenceFlow") { + if(element.nodeName == "sequenceFlow" || getLocalName(element) == "sequenceFlow") { createSequenceFlow(element, scopeActivity, bpmnDiElementIndex, index); } } while(element = element.nextSibling); @@ -315,7 +360,7 @@ function transformExclusiveGateway(element, scopeActivity, sequenceFlows, bpmnDiElementIndex) { var bpmnObject = createFlowElement(element, scopeActivity, null, bpmnDiElementIndex); var outgoingFlows = bpmnObject.sequenceFlows; - var defaultFlowId = bpmnObject.default; + var defaultFlowId = bpmnObject["default"]; // custom handling of sequence flows for exclusive GW: if(!!sequenceFlows && isExecutable) { @@ -390,10 +435,10 @@ } else if(elementType == "parallelGateway") { bpmnObject = transformParallelGateway(element, scopeActivity, sequenceFlows, bpmnDiElementIndex); - } else if(taskElementTypes.indexOf(elementType) != -1) { + } else if(getArrayIndexOf(taskElementTypes, elementType) != -1) { bpmnObject = transformActivity(element, scopeActivity, sequenceFlows, bpmnDiElementIndex); - } else if(eventElementTypes.indexOf(elementType) != -1) { + } else if(getArrayIndexOf(eventElementTypes, elementType) != -1) { bpmnObject = transformEvent(element, scopeActivity, sequenceFlows, bpmnDiElementIndex); } else if(elementType == "laneSet") { @@ -445,7 +490,7 @@ function transformDiElementToObject(element, object) { var properties = {}; - properties["type"] = element.localName; + properties["type"] = getLocalName(element); for(var i=0; element.attributes != null && i