src/js/CanvasPresenter.js
function bind() {
    // listen to global events
    eventBus.subscribe(mindmaps.Event.DOCUMENT_OPENED, function(doc,
        newDocument) {
      showMindMap(doc);

      // if (doc.isNew()) {
      // // edit root node on start
      // var root = doc.mindmap.root;
      // view.editNodeCaption(root);
      // }
    });

    eventBus.subscribe(mindmaps.Event.DOCUMENT_CLOSED, function(doc) {
      view.clear();
    });

    eventBus.subscribe(mindmaps.Event.NODE_MOVED, function(node) {
      view.positionNode(node);
    });

    eventBus.subscribe(mindmaps.Event.NODE_TEXT_CAPTION_CHANGED, function(
        node) {
      view.setNodeText(node, node.getCaption());

      // redraw node in case height has changed
      // TODO maybe only redraw if height has changed
      view.redrawNodeConnectors(node);
    });

    eventBus.subscribe(mindmaps.Event.NODE_CREATED, function(node) {
      view.createNode(node);

      // edit node caption immediately if requested
      if (node.shouldEditCaption) {
        delete node.shouldEditCaption;
        // open parent node when creating a new child and the other
        // children are hidden
        var parent = node.getParent();
        if (parent.foldChildren) {
          var action = new mindmaps.action.OpenNodeAction(parent);
          mindmapModel.executeAction(action);
        }

        // select and go into edit mode on new node
        mindmapModel.selectNode(node);
        // attach creator manually, sometimes the mouseover listener wont fire
        creator.attachToNode(node);
        view.editNodeCaption(node);
      }
    });

    eventBus.subscribe(mindmaps.Event.NODE_DELETED, function(node, parent) {
      // select parent if we are deleting a selected node or a descendant
      var selected = mindmapModel.selectedNode;
      if (node === selected || node.isDescendant(selected)) {
        // deselectCurrentNode();
        mindmapModel.selectNode(parent);
      }

      // update view
      view.deleteNode(node);
      if (parent.isLeaf()) {
        view.removeFoldButton(parent);
      }
    });

    eventBus.subscribe(mindmaps.Event.NODE_SELECTED, selectNode);
    
    eventBus.subscribe(mindmaps.Event.NODE_OPENED, function(node) {
      view.openNode(node);
    });

    eventBus.subscribe(mindmaps.Event.NODE_CLOSED, function(node) {
      view.closeNode(node);
    });

    eventBus.subscribe(mindmaps.Event.NODE_FONT_CHANGED, function(node) {
      view.updateNode(node);
    });

    eventBus.subscribe(mindmaps.Event.NODE_FONT_COLOR_PREVIEW, function(node, color) {
      view.updateFontColor(node, color);
    });

    eventBus.subscribe(mindmaps.Event.NODE_BRANCH_COLOR_CHANGED, function(
        node) {
      view.updateNode(node);
    });
    
    eventBus.subscribe(mindmaps.Event.NODE_BRANCH_COLOR_PREVIEW, function(node, color) {
      view.updateBranchColor(node, color)
    });

    eventBus.subscribe(mindmaps.Event.ZOOM_CHANGED, function(zoomFactor) {
      view.setZoomFactor(zoomFactor);
      view.applyViewZoom();
      view.scaleMap();
    });
  }
function bind() {
    // listen to global events
    eventBus.subscribe(mindmaps.Event.DOCUMENT_OPENED, function(doc,
        newDocument) {
      showMindMap(doc);

      // if (doc.isNew()) {
      // // edit root node on start
      // var root = doc.mindmap.root;
      // view.editNodeCaption(root);
      // }
    });

    eventBus.subscribe(mindmaps.Event.DOCUMENT_CLOSED, function(doc) {
      view.clear();
    });

    eventBus.subscribe(mindmaps.Event.NODE_MOVED, function(node) {
      view.positionNode(node);
    });

    eventBus.subscribe(mindmaps.Event.NODE_TEXT_CAPTION_CHANGED, function(
        node) {
      view.setNodeText(node, node.getCaption());

      // redraw node in case height has changed
      // TODO maybe only redraw if height has changed
      view.redrawNodeConnectors(node);
    });

    eventBus.subscribe(mindmaps.Event.NODE_CREATED, function(node) {
      view.createNode(node);

      // edit node caption immediately if requested
      if (node.shouldEditCaption) {
        delete node.shouldEditCaption;
        // open parent node when creating a new child and the other
        // children are hidden
        var parent = node.getParent();
        if (parent.foldChildren) {
          var action = new mindmaps.action.OpenNodeAction(parent);
          mindmapModel.executeAction(action);
        }

        // select and go into edit mode on new node
        mindmapModel.selectNode(node);
        // attach creator manually, sometimes the mouseover listener wont fire
        creator.attachToNode(node);
        view.editNodeCaption(node);
      }
    });

    eventBus.subscribe(mindmaps.Event.NODE_DELETED, function(node, parent) {
      // select parent if we are deleting a selected node or a descendant
      var selected = mindmapModel.selectedNode;
      if (node === selected || node.isDescendant(selected)) {
        // deselectCurrentNode();
        mindmapModel.selectNode(parent);
      }

      // update view
      view.deleteNode(node);
      if (parent.isLeaf()) {
        view.removeFoldButton(parent);
      }
    });

    eventBus.subscribe(mindmaps.Event.NODE_SELECTED, selectNode);
    
    eventBus.subscribe(mindmaps.Event.NODE_OPENED, function(node) {
      view.openNode(node);
    });

    eventBus.subscribe(mindmaps.Event.NODE_CLOSED, function(node) {
      view.closeNode(node);
    });

    eventBus.subscribe(mindmaps.Event.NODE_FONT_CHANGED, function(node) {
      view.updateNode(node);
    });

    eventBus.subscribe(mindmaps.Event.NODE_FONT_COLOR_PREVIEW, function(node, color) {
      view.updateFontColor(node, color);
    });

    eventBus.subscribe(mindmaps.Event.NODE_BRANCH_COLOR_CHANGED, function(
        node) {
      view.updateNode(node);
    });
    
    eventBus.subscribe(mindmaps.Event.NODE_BRANCH_COLOR_PREVIEW, function(node, color) {
      view.updateBranchColor(node, color)
    });

    eventBus.subscribe(mindmaps.Event.ZOOM_CHANGED, function(zoomFactor) {
      view.setZoomFactor(zoomFactor);
      view.applyViewZoom();
      view.scaleMap();
    });
  }
function bind ( ) { // listen to global events
 eventBus . subscribe ( mindmaps . Event . DOCUMENT_OPENED , function ( doc , newDocument ) { showMindMap ( doc ) ; // if (doc.isNew()) {
 // // edit root node on start
 // var root = doc.mindmap.root;
 // view.editNodeCaption(root);
 // }
 } ) ; eventBus . subscribe ( mindmaps . Event . DOCUMENT_CLOSED , function ( doc ) { view . clear ( ) ; } ) ; eventBus . subscribe ( mindmaps . Event . NODE_MOVED , function ( node ) { view . positionNode ( node ) ; } ) ; eventBus . subscribe ( mindmaps . Event . NODE_TEXT_CAPTION_CHANGED , function ( node ) { view . setNodeText ( node , node . getCaption ( ) ) ; // redraw node in case height has changed
 // TODO maybe only redraw if height has changed
 view . redrawNodeConnectors ( node ) ; } ) ; eventBus . subscribe ( mindmaps . Event . NODE_CREATED , function ( node ) { view . createNode ( node ) ; // edit node caption immediately if requested
 if ( node . shouldEditCaption ) { delete node . shouldEditCaption ; // open parent node when creating a new child and the other
 // children are hidden
 var parent = node . getParent ( ) ; if ( parent . foldChildren ) { var action = new mindmaps . action . OpenNodeAction ( parent ) ; mindmapModel . executeAction ( action ) ; } // select and go into edit mode on new node
 mindmapModel . selectNode ( node ) ; // attach creator manually, sometimes the mouseover listener wont fire
 creator . attachToNode ( node ) ; view . editNodeCaption ( node ) ; } } ) ; eventBus . subscribe ( mindmaps . Event . NODE_DELETED , function ( node , parent ) { // select parent if we are deleting a selected node or a descendant
 var selected = mindmapModel . selectedNode ; if ( node === selected || node . isDescendant ( selected ) ) { // deselectCurrentNode();
 mindmapModel . selectNode ( parent ) ; } // update view
 view . deleteNode ( node ) ; if ( parent . isLeaf ( ) ) { view . removeFoldButton ( parent ) ; } } ) ; eventBus . subscribe ( mindmaps . Event . NODE_SELECTED , selectNode ) ; eventBus . subscribe ( mindmaps . Event . NODE_OPENED , function ( node ) { view . openNode ( node ) ; } ) ; eventBus . subscribe ( mindmaps . Event . NODE_CLOSED , function ( node ) { view . closeNode ( node ) ; } ) ; eventBus . subscribe ( mindmaps . Event . NODE_FONT_CHANGED , function ( node ) { view . updateNode ( node ) ; } ) ; eventBus . subscribe ( mindmaps . Event . NODE_FONT_COLOR_PREVIEW , function ( node , color ) { view . updateFontColor ( node , color ) ; } ) ; eventBus . subscribe ( mindmaps . Event . NODE_BRANCH_COLOR_CHANGED , function ( node ) { view . updateNode ( node ) ; } ) ; eventBus . subscribe ( mindmaps . Event . NODE_BRANCH_COLOR_PREVIEW , function ( node , color ) { view . updateBranchColor ( node , color ) } ) ; eventBus . subscribe ( mindmaps . Event . ZOOM_CHANGED , function ( zoomFactor ) { view . setZoomFactor ( zoomFactor ) ; view . applyViewZoom ( ) ; view . scaleMap ( ) ; } ) ; }
Hook up with EventBus.
Hook up with EventBus .