Creating header package and dropdown component

This commit is contained in:
Bruno Alves de Faria committed 2017-03-21 10:16:46 -03:00
1 parent 04e9a85def
commit 2d52c9ef0a
17 files changed
+243 -49

No files matched your search

@@ -1,3 +1,5 @@
import { $ } from 'meteor/jquery';
import { _ } from 'meteor/underscore';
import { OHIF } from 'meteor/ohif:core';
// Allow attaching to jQuery selectors
@@ -61,6 +63,19 @@ class Bounded {
// Add the bounded class to the element
this.$element.addClass('bounded');
// Handle the positioning on window resize
const $window = $(window);
const windowResizeHandler = () => {
// Check if the element is still in DOM and remove the handler if it is not
if (!this.$element.closest(document.documentElement).length) {
$window.off('resize', windowResizeHandler);
}
this.$element.trigger('spatialChanged');
};
$window.on('resize', windowResizeHandler);
// Trigger the bounding check for the first timepoint
setTimeout(() => this.$element.trigger('spatialChanged'));
}
@@ -0,0 +1,29 @@
import { Template } from 'meteor/templating';
import { Blaze } from 'meteor/blaze';
import { OHIF } from 'meteor/ohif:core';
OHIF.ui.showDropdown = (items=[], options={}) => {
// Prepare the method to destroy the view
let view;
const destroyView = () => Blaze.remove(view);
const templateData = {
items,
options,
destroyView
};
// Render the dialog with the given template and data
const parentElement = options.parentElement || document.body;
view = Blaze.renderWithData(Template.dropdownForm, templateData, parentElement);
};
Meteor.startup(() => {
OHIF.ui.showDropdown([{
text: 'test 1',
action: () => console.warn('test1Clicked'),
separatorAfter: true
}, {
text: 'test 2',
action: () => console.warn('test2Clicked')
}]);
});
+1
View File
@@ -4,6 +4,7 @@ import './dialog/display.js';
import './dialog/spatial.js';
import './dialog/unsavedChangesDialog.js';
import './draggable/draggable.js';
import './dropdown/dropdown.js';
import './dropdown/form.js';
import './resizable/resizable.js';
import './unsavedChanges/unsavedChanges.js';