2015-02-02 13:46:21 +00:00
|
|
|
'use strict';
|
2014-12-07 12:08:50 +00:00
|
|
|
|
2015-04-28 11:57:03 +00:00
|
|
|
var inherits = require('inherits');
|
2014-12-07 12:08:50 +00:00
|
|
|
|
2015-04-28 11:57:03 +00:00
|
|
|
var is = require('../../../util/ModelUtil').is;
|
2014-12-07 12:08:50 +00:00
|
|
|
|
2015-04-28 11:57:03 +00:00
|
|
|
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor');
|
2014-12-07 12:08:50 +00:00
|
|
|
|
|
|
|
|
2015-04-28 11:57:03 +00:00
|
|
|
function AppendBehavior(eventBus, elementFactory, bpmnRules) {
|
|
|
|
|
|
|
|
CommandInterceptor.call(this, eventBus);
|
|
|
|
|
|
|
|
// assign correct shape position unless already set
|
|
|
|
|
|
|
|
this.preExecute('shape.append', function(context) {
|
|
|
|
|
|
|
|
var source = context.source,
|
|
|
|
shape = context.shape;
|
2014-12-07 12:08:50 +00:00
|
|
|
|
|
|
|
if (!context.position) {
|
|
|
|
|
2015-04-28 11:57:03 +00:00
|
|
|
if (is(shape, 'bpmn:TextAnnotation')) {
|
2014-12-07 12:08:50 +00:00
|
|
|
context.position = {
|
|
|
|
x: source.x + source.width / 2 + 75,
|
|
|
|
y: source.y - (50) - shape.height / 2
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
context.position = {
|
|
|
|
x: source.x + source.width + 80 + shape.width / 2,
|
|
|
|
y: source.y + source.height / 2
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2015-04-28 11:57:03 +00:00
|
|
|
}, true);
|
2014-12-07 12:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-28 11:57:03 +00:00
|
|
|
AppendBehavior.$inject = [ 'eventBus', 'elementFactory', 'bpmnRules' ];
|
|
|
|
|
|
|
|
inherits(AppendBehavior, CommandInterceptor);
|
2014-12-07 12:08:50 +00:00
|
|
|
|
|
|
|
module.exports = AppendBehavior;
|