Skip to content
Permalink
Browse files

Add workaround for queryui problem

  • Loading branch information...
flack committed Oct 6, 2019
1 parent 421f0ee commit 9550b96eb81f935031a3752b661bdf6954f11722
Showing with 29 additions and 1 deletion.
  1. +29 −1 static/midcom.workflow/workflow.js
@@ -157,7 +157,7 @@ function create_dialog(control, title, url) {
$('.midcom-workflow-dialog .ui-dialog-content').dialog('close');
}

var dialog, iframe, spinner,
var dialog, iframe, spinner, is_scrolling,
config = {
dialogClass: 'midcom-workflow-dialog',
buttons: [],
@@ -184,6 +184,28 @@ function create_dialog(control, title, url) {
});
}

// Workaround for jqueryui incompatibility between position widget & css fixed position
function keep_dialog_fixed (event) {
var ui_dialog = dialog.closest('.ui-dialog'),
viewport_position = ui_dialog[0].getBoundingClientRect();

window.clearTimeout(is_scrolling);

ui_dialog.css({
position: 'fixed',
top: viewport_position.top + 'px',
left: viewport_position.left + 'px'
});

is_scrolling = setTimeout(function() {
ui_dialog.css({
position: 'absolute',
top: ui_dialog.offset().top + 'px',
left: ui_dialog.offset().left + 'px'
});
}, 500);
}

if ($('#midcom-dialog').length > 0) {
dialog = $('#midcom-dialog');
iframe = dialog.find('> iframe');
@@ -236,6 +258,12 @@ function create_dialog(control, title, url) {
}
});
})
.on('dialogopen', function() {
window.addEventListener('scroll', keep_dialog_fixed, false);
})
.on('dialogclose', function() {
window.removeEventListener('scroll', keep_dialog_fixed, false);
})
.appendTo($('body'));
}

0 comments on commit 9550b96

Please sign in to comment.
You can’t perform that action at this time.