PWV-1: Refactoring ohif:studylist package
This commit is contained in:
1 parent
984ef94403
commit
4d79bf84a8
79 files changed
+450
-551
No files matched your search
@@ -36,10 +36,15 @@ class Bounded {
|
||||
options(options={}) {
|
||||
// Process the given options and store it in the instance
|
||||
const { boundingElement, allowResizing } = options;
|
||||
this.boundingElement = boundingElement || window;
|
||||
this.boundingElement = boundingElement;
|
||||
this.$boundingElement = $(this.boundingElement);
|
||||
this.allowResizing = allowResizing;
|
||||
|
||||
// Check for fixed positioning
|
||||
if (this.$element.css('position') === 'fixed') {
|
||||
this.boundingElement = window;
|
||||
}
|
||||
|
||||
// Destroy and initialize again the instance
|
||||
this.destroy();
|
||||
this.init();
|
||||
@@ -55,6 +60,9 @@ class Bounded {
|
||||
|
||||
// Add the bounded class to the element
|
||||
this.$element.addClass('bounded');
|
||||
|
||||
// Trigger the bounding check for the first timepoint
|
||||
setTimeout(() => this.$element.trigger('spatialChanged'));
|
||||
}
|
||||
|
||||
// Destroy this instance, returning the element to its previous state
|
||||
@@ -70,12 +78,26 @@ class Bounded {
|
||||
// Create the result object
|
||||
const result = {};
|
||||
|
||||
// Check if the element is the window
|
||||
if (element === window) {
|
||||
const $window = $(window);
|
||||
const width = $window.outerWidth();
|
||||
const height = $window.outerHeight();
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x0: 0,
|
||||
y0: 0,
|
||||
x1: width,
|
||||
y1: height
|
||||
};
|
||||
}
|
||||
|
||||
// Get the jQuery object for the element
|
||||
const el = element === window ? window.document.body : element;
|
||||
const $element = $(el);
|
||||
const $element = $(element);
|
||||
|
||||
// Get the element style
|
||||
const style = el.style;
|
||||
const style = element.style;
|
||||
|
||||
// Get the integer numbers for element's width
|
||||
if (style.width && style.width.indexOf('px') > -1) {
|
||||
@@ -91,10 +113,13 @@ class Bounded {
|
||||
result.height = $element.outerHeight();
|
||||
}
|
||||
|
||||
// Get the position property based on the element position CSS attribute
|
||||
const positionProperty = $element.css('position') === 'fixed' ? 'position' : 'offset';
|
||||
|
||||
// Get the element's start position
|
||||
const offset = $element.offset();
|
||||
result.x0 = offset.left;
|
||||
result.y0 = offset.top;
|
||||
const position = $element[positionProperty]();
|
||||
result.x0 = position.left;
|
||||
result.y0 = position.top;
|
||||
|
||||
// Get the element's end position
|
||||
result.x1 = result.x0 + result.width;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { Blaze } from 'meteor/blaze';
|
||||
import { _ } from 'meteor/underscore';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
OHIF.ui.showFormDropdown = (templateName, dropdownData) => {
|
||||
// Check if the given template exists
|
||||
const template = Template[templateName];
|
||||
if (!template) {
|
||||
throw {
|
||||
name: 'TEMPLATE_NOT_FOUND',
|
||||
message: `Template ${templateName} not found.`
|
||||
};
|
||||
}
|
||||
|
||||
// Prepare the method to destroy the view
|
||||
let view;
|
||||
const destroyView = () => Blaze.remove(view);
|
||||
const templateData = _.extend({}, dropdownData, {
|
||||
destroyView
|
||||
});
|
||||
|
||||
// Render the dialog with the given template and data
|
||||
view = Blaze.renderWithData(template, templateData, document.body);
|
||||
|
||||
// Return the dropdown element to enable position manipulation
|
||||
const dropdown = view.firstNode();
|
||||
return dropdown;
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
import './bounded/bounded.js';
|
||||
import './dialog/form.js';
|
||||
import './draggable/draggable.js';
|
||||
import './dropdown/form.js';
|
||||
import './resizable/resizable.js';
|
||||
Reference in new issue
Block a user