'use strict';
|
|
function ModuleListContextPadProvider(contextPad, popupMenu, canvas, translate, eventBus) {
|
this._contextPad = contextPad;
|
this._popupMenu = popupMenu;
|
this._canvas = canvas;
|
this._translate = translate;
|
this._eventBus = eventBus;
|
|
contextPad.registerProvider(this);
|
}
|
|
|
ModuleListContextPadProvider.$inject = [
|
'contextPad',
|
'popupMenu',
|
'canvas',
|
'translate',
|
'eventBus'
|
];
|
|
module.exports = ModuleListContextPadProvider;
|
|
|
ModuleListContextPadProvider.prototype.getContextPadEntries = function(element) {
|
var self = this,
|
translate = this._translate;
|
|
var actions = {
|
'set-modules': {
|
group: 'edit',
|
className: 'bpmn-icon-modules',
|
title: translate('Set Modules'),
|
action: {
|
click: function(event, element) {
|
|
var opts = getStartPosition(self._canvas, self._contextPad, element);
|
|
// or fallback to current cursor position
|
opts.cursor = {
|
x: event.x,
|
y: event.y
|
};
|
|
self._eventBus.fire('modulelist.element.click', { element, opts });
|
}
|
}
|
}
|
};
|
|
return actions;
|
};
|
|
|
// helpers //////////////////////
|
|
function getStartPosition(canvas, contextPad, element) {
|
|
var Y_OFFSET = 5;
|
|
var diagramContainer = canvas.getContainer(),
|
pad = contextPad.getPad(element).html;
|
|
var diagramRect = diagramContainer.getBoundingClientRect(),
|
padRect = pad.getBoundingClientRect();
|
|
var top = padRect.top - diagramRect.top;
|
var left = padRect.left - diagramRect.left;
|
|
var pos = {
|
x: left,
|
y: top + padRect.height + Y_OFFSET
|
};
|
|
return pos;
|
}
|