var graph = new joint.dia.Graph({
});
var paper = new joint.dia.Paper({
el: $('#myholder'),
width: 1800,
height: 800,
model: graph,
markAvailable: true,
gridSize:10,
snapLinks: true,
linkPinning: false,
validateConnection: function(vs, ms, vt, mt, e, vl) {
console.log(e);
if (e === 'target') {
// target requires an input port to connect
console.log(mt.getAttribute('class'));
if (!mt || !mt.getAttribute('class') || mt.getAttribute('class').indexOf('port-body') < 0) return false;
// check whether the port is being already used
var portUsed = _.find(this.model.getLinks(), function(link) {
link.get('target').port === mt.getAttribute('port'));
});
return !portUsed;
} else { // e === 'source'
// source requires an output port to connect
return ms && ms.getAttribute('class') && ms.getAttribute('class').indexOf('port-body') >= 0;
}
}, defaultLink: new joint.dia.Link({
router: { name: 'manhattan' },
connection : {name: 'orthogonal'},
attrs: {
'.marker-target': { d: 'M 10 0 L 0 5 L 10 10 z', fill: '#fff', stroke: '#000' },
'.link-tools .tool-remove circle, .marker-vertex': { r: 8 },
'.connection': {
stroke: '#000', 'stroke-width': 1
//filter: { name: 'dropShadow', args: { dx: 1, dy: 1, blur: 2 } }
}
}
})
});