2016-07-12 20:37:53 +02:00
|
|
|
import { OHIF } from 'meteor/ohif:core';
|
|
|
|
|
|
2016-06-29 22:39:40 +02:00
|
|
|
Template.toolbarSectionButton.helpers({
|
|
|
|
|
activeClass() {
|
2016-07-22 18:23:36 +02:00
|
|
|
// TODO: Find a way to prevent the 'flash' after a click, but before this helper runs
|
2016-06-29 22:39:40 +02:00
|
|
|
const instance = Template.instance();
|
|
|
|
|
|
|
|
|
|
// Check if the current tool is the active one
|
|
|
|
|
if (instance.data.id === Session.get('ToolManagerActiveTool')) {
|
|
|
|
|
// Return the active class
|
|
|
|
|
return 'active';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-07-01 21:40:28 +02:00
|
|
|
|
|
|
|
|
Template.toolbarSectionButton.events({
|
|
|
|
|
'click .imageViewerTool'(event, instance) {
|
2016-08-29 14:10:51 +02:00
|
|
|
// Stop here if the tool is disabled
|
|
|
|
|
if ($(event.currentTarget).hasClass('disabled')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-22 18:23:36 +02:00
|
|
|
const tool = event.currentTarget.id;
|
|
|
|
|
const elements = instance.$('.imageViewerViewport');
|
2016-07-01 21:40:28 +02:00
|
|
|
|
2016-07-22 18:23:36 +02:00
|
|
|
const activeTool = toolManager.getActiveTool();
|
2016-07-01 21:40:28 +02:00
|
|
|
if (tool === activeTool) {
|
2016-07-22 18:23:36 +02:00
|
|
|
const defaultTool = toolManager.getDefaultTool();
|
|
|
|
|
log.info('Setting active tool to: ' + defaultTool);
|
2016-07-01 21:40:28 +02:00
|
|
|
toolManager.setActiveTool(defaultTool, elements);
|
|
|
|
|
} else {
|
2016-07-22 18:23:36 +02:00
|
|
|
log.info('Setting active tool to: ' + tool);
|
2016-07-01 21:40:28 +02:00
|
|
|
toolManager.setActiveTool(tool, elements);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'click .imageViewerCommand'(event, instance) {
|
2016-08-29 14:10:51 +02:00
|
|
|
// Stop here if the tool is disabled
|
|
|
|
|
if ($(event.currentTarget).hasClass('disabled')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-22 18:23:36 +02:00
|
|
|
const command = event.currentTarget.id;
|
2016-07-23 15:56:36 +02:00
|
|
|
if (!OHIF.viewer.functionList || !OHIF.viewer.functionList.hasOwnProperty(command)) {
|
2016-07-01 21:40:28 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-22 18:23:36 +02:00
|
|
|
const activeViewport = Session.get('activeViewport');
|
|
|
|
|
const element = $('.imageViewerViewport').get(activeViewport);
|
2016-07-01 21:40:28 +02:00
|
|
|
OHIF.viewer.functionList[command](element);
|
|
|
|
|
}
|
|
|
|
|
});
|