LT-352: Fixing Non-Target dialog positioning
This commit is contained in:
1 parent
d84435a6f1
commit
a21479e1d1
5 files changed
+55
-5
No files matched your search
@@ -43,10 +43,19 @@ Template.dialogForm.onCreated(() => {
|
||||
Template.dialogForm.onRendered(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
// Create the bootstrap modal
|
||||
const $modal = instance.$('.modal');
|
||||
$modal.modal({
|
||||
// Allow options ovewrite
|
||||
const modalOptions = _.extend({
|
||||
backdrop: 'static',
|
||||
keyboard: false
|
||||
});
|
||||
}, instance.data.modalOptions);
|
||||
|
||||
const $modal = instance.$('.modal');
|
||||
|
||||
// Create the bootstrap modal
|
||||
$modal.modal(modalOptions);
|
||||
|
||||
const position = instance.data.position;
|
||||
if (position) {
|
||||
OHIF.ui.repositionDialog($modal, position.x, position.y);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
OHIF.ui.repositionDialog = ($modal, x, y) => {
|
||||
const $dialog = $modal.find('.modal-dialog');
|
||||
|
||||
// Remove the margins and set its position as fixed
|
||||
$dialog.css({
|
||||
margin: 0,
|
||||
position: 'fixed'
|
||||
}).bounded();
|
||||
|
||||
// Temporarily show the modal
|
||||
const isVisible = $modal.is(':visible');
|
||||
$modal.show();
|
||||
|
||||
// Calculate the center position on screen
|
||||
const height = $dialog.outerHeight();
|
||||
const width = $dialog.outerWidth();
|
||||
const left = parseInt(x - (width / 2));
|
||||
const top = parseInt(y - (height / 2));
|
||||
|
||||
// Reposition the modal and readjust it to the window boundaries if needed
|
||||
$dialog.css({
|
||||
left,
|
||||
top
|
||||
}).trigger('spatialChanged');
|
||||
|
||||
// Switch the modal to its previous visibility state
|
||||
$modal.toggle(isVisible);
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
import './bounded/bounded.js';
|
||||
import './dialog/form.js';
|
||||
import './dialog/spatial.js';
|
||||
import './draggable/draggable.js';
|
||||
import './dropdown/form.js';
|
||||
import './resizable/resizable.js';
|
||||
Reference in new issue
Block a user