(function(global){ // BEGIN CLOSURE
var Joint = global.Joint,
Element = Joint.dia.Element,
point = Joint.point;
/**
* @name Joint.dia.mq
* @namespace Holds functionality related to MergeQuest
*/
var mq = Joint.dia.mq = {};
/**
* Predefined arrow. You are free to use this arrow as the option parameter to joint method.
* @name arrow
* @memberOf Joint.dia.mq
* @example
* var arrow = Joint.dia.org.arrow;
*/
mq.arrow = {
startArrow: {type: 'none'},
endArrow: {type: 'none'},
attrs: {"stroke-dasharray": "none", 'stroke-width': 2, stroke: 'gray' }
};
mq.basicarrow = {
startArrow: {type: 'none'},
endArrow: {type: 'basic', size: 5},
attrs: {"stroke-dasharray": "none" }
};
mq.doublearrow = {
startArrow: {type: "basic", size: 5},
endArrow: {type: "basic", size: 5},
attrs: {"stroke-dasharray": "none"}
};
/**
* Mergequest element
* @methodOf Joint.dia.mq
*/
mq.Member = Element.extend({
object: 'Member',
module: 'mq',
init: function(properties) {
var p = Joint.DeepSupplement(this.properties, properties, {
attrs: { fill: 'white', stroke: '#008e09', 'stroke-width': 2 },
name: '',
nameAttrs: { 'font-weight': 'bold' },
labelOffsetY: 10,
radius: 10,
shadow: true,
avatar: '',
padding: 5
});
this.setWrapper(this.paper.rect(p.rect.x, p.rect.y, p.rect.width, p.rect.height, p.radius).attr(p.attrs));
if (p.avatar) {
this.addInner(this.paper.image(p.avatar, p.rect.x + p.padding, p.rect.y + p.padding, p.rect.height - 2*p.padding, p.rect.height - 2*p.padding));
p.labelOffsetX = p.rect.height;
}
this.addInner(this.getNameElement());
},
getNameElement: function() {
var
p = this.properties,
bb = this.wrapper.getBBox(),
t = this.paper.text(bb.x, bb.y, p.name).attr(p.nameAttrs || {}),
tbb = t.getBBox();
t.translate(bb.x - tbb.x + p.labelOffsetX,
bb.y - tbb.y + p.labelOffsetY);
return t;
}
});
})(this); // END CLOSURE