JointJS TooledView plugin

A plugin for having toold added on elements on JointJS

Example on using TooledView plugin for JointJS

  1. Add tooledViewPlugin.js's code to your code
  2. Extend your Element's constructor with the interface in this way:
  3. 
    joint.shapes.devs.TooledModel = joint.shapes.devs.Model.extend( _.extend({}, joint.plugins.TooledModelInterface, {
       
        markup: '<g class="rotatable"><g class="scalable"><rect class="body"/></g><text class="label"/><g class="inPorts"/><g class="outPorts"/><g class="moveTool"/><g class="resizeTool"/><g class="portsTool"/></g>',
        //<g class="moveTool"/><g class="resizeTool"/><g class="portsTool"/> to be used as needed
        defaults: joint.util.deepSupplement({
            type: 'devs.TooledModel',
        }, joint.shapes.devs.Model.prototype.defaults)
        
    }));
    
  4. Extend that element's View with this plugin's view joint.plugins.TooledViewInterface
  5. 
    joint.shapes.devs.TooledModelView = joint.shapes.devs.ModelView.extend(
                                                                                joint.plugins.TooledViewInterface,
                                                                                //possibly other interfaces
    );
    

  6. Make the new element
  7. 
    var elem = new joint.shapes.devs.TooledModel({
        attrs: {
            '.label': { text: "I'm overriding the label's name"}
        },
        portsTool: false, //Deactivate some of the tools if you want
    });
    

  8. Add the element to the paper
  9. graph.addCell(elem);

Done! :D