Resources/public/js/editor/src/diagram/Diagram.js
/**
 * Object representing the map diagram
 *
 * @param element
 * @param map
 * @constructor
 */
Object representing the map diagram
@param element
@param map
@constructor
Object representing the map diagram @param element @param map @constructor
function Diagram (element, map) {
  this.map = map;
  this.graph = new joint.dia.Graph;
  this.movedStepPosition = null;
  this.changedPathVertices = null;
  this.ongoingAction = null;
  this.paper = new joint.dia.Paper({
    el: element,
    gridSize: 1,
    height: 900,
    width: 900,
    model: this.graph,
    interactive: function (cellView) {
      if (cellView.model instanceof joint.dia.Link) {
        return {
          vertexAdd: false
        };
      }
      return true;
    },
    linkView: joint.dia.LinkView.extend({
      pointerdblclick: function (evt, x, y) {
        if (joint.V(evt.target).hasClass('connection') || joint.V(evt.target).hasClass('connection-wrap')) {
          this.addVertex({
            x: x,
            y: y
          });
        }
      },
      options: _.defaults({
        linkToolsOffset: 100,
        shortLinkLength: 10000
      }, joint.dia.LinkView.prototype.options)
    })
  });
  this.generateSteps(this.map.steps, this.map.graphPositions.steps);
  this.generatePaths(this.map.paths, this.map.graphPositions.paths);
}
function Diagram ( element , map ) { this . map = map ; this . graph = new joint . dia . Graph ; this . movedStepPosition = null ; this . changedPathVertices = null ; this . ongoingAction = null ; this . paper = new joint . dia . Paper ( { el : element , gridSize : 1 , height : 900 , width : 900 , model : this . graph , interactive : function ( cellView ) { if ( cellView . model instanceof joint . dia . Link ) { return { vertexAdd : false } ; } return true ; } , linkView : joint . dia . LinkView . extend ( { pointerdblclick : function ( evt , x , y ) { if ( joint . V ( evt . target ) . hasClass ( 'connection' ) || joint . V ( evt . target ) . hasClass ( 'connection-wrap' ) ) { this . addVertex ( { x : x , y : y } ) ; } } , options : _ . defaults ( { linkToolsOffset : 100 , shortLinkLength : 10000 } , joint . dia . LinkView . prototype . options ) } ) } ) ; this . generateSteps ( this . map . steps , this . map . graphPositions . steps ) ; this . generatePaths ( this . map . paths , this . map . graphPositions . paths ) ; }
Object representing the map diagram
 @param element
 @param map
 @constructor
Object representing the map diagram @param element @param map @constructor
// Variable used to avoid calling some callbacks after events // Disable the default vertex add functionality on pointerdown. // Always scale down to 2 the link tools