UNPKG

jointjs

Version:

JavaScript diagramming library

8 lines (6 loc) 2.78 kB
/*! JointJS v3.1.1 (2019-10-28) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ this.joint=this.joint||{},this.joint.shapes=this.joint.shapes||{},function(t,e,r,a){"use strict";var o=e.Generic.define("devs.Model",{inPorts:[],outPorts:[],size:{width:80,height:80},attrs:{".":{magnet:!1},".label":{text:"Model","ref-x":.5,"ref-y":10,"font-size":18,"text-anchor":"middle",fill:"#000"},".body":{"ref-width":"100%","ref-height":"100%",stroke:"#000"}},ports:{groups:{in:{position:{name:"left"},attrs:{".port-label":{fill:"#000"},".port-body":{fill:"#fff",stroke:"#000",r:10,magnet:!0}},label:{position:{name:"left",args:{y:10}}}},out:{position:{name:"right"},attrs:{".port-label":{fill:"#000"},".port-body":{fill:"#fff",stroke:"#000",r:10,magnet:!0}},label:{position:{name:"right",args:{y:10}}}}}}},{markup:'<g class="rotatable"><rect class="body"/><text class="label"/></g>',portMarkup:'<circle class="port-body"/>',portLabelMarkup:'<text class="port-label"/>',initialize:function(){e.Generic.prototype.initialize.apply(this,arguments),this.on("change:inPorts change:outPorts",this.updatePortItems,this),this.updatePortItems()},updatePortItems:function(t,e,r){var o=a.uniq(this.get("inPorts")),i=a.difference(a.uniq(this.get("outPorts")),o),s=this.createPortItems("in",o),n=this.createPortItems("out",i);this.prop("ports/items",s.concat(n),a.assign({rewrite:!0},r))},createPortItem:function(t,e){return{id:e,group:t,attrs:{".port-label":{text:e}}}},createPortItems:function(t,e){return a.toArray(e).map(this.createPortItem.bind(this,t))},_addGroupPort:function(t,e,r){var o=this.get(e);return this.set(e,Array.isArray(o)?o.concat(t):[t],r)},addOutPort:function(t,e){return this._addGroupPort(t,"outPorts",e)},addInPort:function(t,e){return this._addGroupPort(t,"inPorts",e)},_removeGroupPort:function(t,e,r){return this.set(e,a.without(this.get(e),t),r)},removeOutPort:function(t,e){return this._removeGroupPort(t,"outPorts",e)},removeInPort:function(t,e){return this._removeGroupPort(t,"inPorts",e)},_changeGroup:function(t,e,r){return this.prop("ports/groups/"+t,a.isObject(e)?e:{},r)},changeInGroup:function(t,e){return this._changeGroup("in",t,e)},changeOutGroup:function(t,e){return this._changeGroup("out",t,e)}}),i=o.define("devs.Atomic",{size:{width:80,height:80},attrs:{".label":{text:"Atomic"}}}),s=o.define("devs.Coupled",{size:{width:200,height:300},attrs:{".label":{text:"Coupled"}}}),n=r.Link.define("devs.Link",{attrs:{".connection":{"stroke-width":2}}});t.Atomic=i,t.Coupled=s,t.Link=n,t.Model=o}(this.joint.shapes.devs=this.joint.shapes.devs||{},joint.shapes.basic,joint.dia,joint.util);