Fix OHIF global variable definition bug in OHIF Viewer, moved resizeViewportElements to viewerbase

This commit is contained in:
Erik Ziegler 2015-12-15 10:20:57 -05:00
parent 37fa29cce4
commit 86c8a32e2a
8 changed files with 31 additions and 48 deletions

View File

@ -1,16 +1,3 @@
var resizeTimer;
// TODO= Move this and resizeViewportElements to viewerbase
function handleResize() {
// Avoid doing DOM manipulation during the resize handler
// because it is fired very often.
// Resizing is therefore performed 100 ms after the resize event stops.
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
resizeViewportElements();
}, 100);
}
Template.viewer.onCreated(function() {
// Attach the Window resize listener
$(window).on('resize', handleResize);

View File

@ -1,25 +1,10 @@
function resizeViewports() {
log.info("viewer resizeViewports");
// Handle resizing of image viewer viewports
// For some reason, this seems to need to be on
// another delay, or the resizing won't work properly
viewportResizeTimer = setTimeout(function() {
var elements = $('.imageViewerViewport');
elements.each(function(index) {
var element = this;
if (!element) {
return;
}
cornerstone.resize(element, true);
});
}, 1);
}
Template.viewer.onCreated(function() {
// Attach the Window resize listener
$(window).on('resize', handleResize);
log.info("viewer onCreated");
OHIF = {
OHIF = window.OHIF || {
viewer: {}
};
@ -96,15 +81,4 @@ Template.viewer.onCreated(function() {
Template.viewer.onDestroyed(function() {
log.info("onDestroyed");
OHIF.viewer.updateImageSynchronizer.destroy();
});
// Avoid doing DOM manipulation during the resize handler
// because it is fired very often.
// Resizing is therefore performed 100 ms after the resize event stops.
var resizeTimer;
$(window).on('resize', function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
resizeViewports();
}, 100);
});

View File

@ -65,7 +65,7 @@
bottom: 0
overflow: auto
width: 100%
padding-bottom: 20px
tr.selectedRow
background: #F5F5F5 !important

View File

@ -62,13 +62,11 @@ Package.onUse(function (api) {
// Library functions
api.addFiles('lib/uuid.js', 'client');
api.addFiles('lib/resizeViewportElements.js', 'client');
api.addFiles('lib/toggleLesionTrackerTools.js', 'client');
api.addFiles('lib/clearTools.js', 'client');
// Export lesionTable function for activate measurements
api.export('activateLesion','client');
api.export('resizeViewportElements','client');
api.export('toggleLesionTrackerTools', 'client');
api.export('clearTools', 'client');
api.export('measurementManagerDAL', 'client');

View File

@ -23,6 +23,13 @@ Template.playClipButton.helpers({
'isPlaying': function() {
Session.get('UpdateCINE');
var activeViewport = Session.get('activeViewport');
// TODO=Check best way to make sure this is always defined
// Right now it is initialized in enableHotkeys AND in
// imageViewer onCreated, but this appears to break some things
if (!OHIF.viewer.isPlaying) {
return;
}
return !!OHIF.viewer.isPlaying[activeViewport];
}
});

View File

@ -1,3 +1,15 @@
var resizeTimer;
handleResize = function() {
// Avoid doing DOM manipulation during the resize handler
// because it is fired very often.
// Resizing is therefore performed 100 ms after the resize event stops.
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
resizeViewportElements();
}, 100);
};
// Resize viewport elements
resizeViewportElements = function() {
viewportResizeTimer = setTimeout(function() {

View File

@ -72,7 +72,10 @@ toolManager = {
mouse: cornerstoneTools.arrowAnnotate,
touch: cornerstoneTools.arrowAnnotateTouch
});
activeTool = OHIF.viewer.defaultTool;
if (OHIF.viewer.defaultTool) {
activeTool = OHIF.viewer.defaultTool;
}
configureTools();
initialized = true;

View File

@ -121,10 +121,12 @@ Package.onUse(function (api) {
api.addFiles('lib/enableHotkeys.js', 'client');
api.addFiles('lib/viewportFunctions.js', 'client');
api.addFiles('lib/WLPresets.js', 'client');
api.addFiles('lib/resizeViewportElements.js', 'client');
api.addFiles('lib/encodeQueryData.js', 'server');
//api.export('accountsConfig', 'client');
api.export('resizeViewportElements','client');
api.export('handleResize','client');
api.export('enableHotkeys', 'client');
api.export('enablePrefetchOnElement', 'client');
api.export('displayReferenceLines', 'client');