Fixing that Workflows activities are not measured in relative coordinates

This commit is contained in:
Lombiq 2015-11-24 14:23:20 +01:00
parent 188fabe233
commit c5fb96ca4f
2 changed files with 594 additions and 574 deletions

View File

@ -75,10 +75,18 @@
$('#activity-editor').droppable({ drop: function(event, ui) { $('#activity-editor').droppable({ drop: function(event, ui) {
var activityName = ui.draggable.data('activity-name'); var activityName = ui.draggable.data('activity-name');
if (activityName && activityName.length) { if (activityName && activityName.length) {
createActivity(activityName, event.pageY, event.pageX); var offset = $(this).offset();
if (displaySaveMessage()) {
createActivity(activityName, event.pageY - offset.top - 40, event.pageX - offset.left); /* The displaySaveMessage's height is 40px */
}
else {
createActivity(activityName, event.pageY - offset.top, event.pageX - offset.left);
}
}
if (displaySaveMessage()) {
var activityPosition = ui.position;
activityPosition.top += 40; /* The displaySaveMessage's height is 40px */
} }
displaySaveMessage();
} }
}); });
@ -174,8 +182,11 @@
elt.viewModel.edit = edit; elt.viewModel.edit = edit;
} }
var canvasWidth = $('#activity-editor').width();
var domWidth = $('#' + clientId).width() + 25; /* width + padding */
dom.css('top', top + 'px'); dom.css('top', top + 'px');
dom.css('left', left + 'px'); dom.css('left', left + domWidth > canvasWidth ? canvasWidth - domWidth : left + 'px');
jsPlumb.repaint(elt.viewModel.clientId); jsPlumb.repaint(elt.viewModel.clientId);
dom.on("click", function () { dom.on("click", function () {
@ -246,7 +257,15 @@
} }
function displaySaveMessage() { function displaySaveMessage() {
$("#save-message").show(); var saveMessage = $("#save-message");
if (saveMessage.css('display') === "none") {
saveMessage.show();
return true;
}
else {
return false;
}
} }
var refreshToolbar = function(target) { var refreshToolbar = function(target) {

View File

@ -88,6 +88,7 @@
} }
#workflow-container { #workflow-container {
position: relative;
} }
#editor-wrapper { #editor-wrapper {