2016-11-04 10:31:15 -02:00
|
|
|
setActiveViewport = element => {
|
2015-12-09 15:48:24 +01:00
|
|
|
if (!element) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 10:31:15 -02:00
|
|
|
const viewportIndex = $('.imageViewerViewport').index(element);
|
|
|
|
|
const jQueryElement = $(element);
|
2015-12-09 15:48:24 +01:00
|
|
|
|
|
|
|
|
// When an ActivateViewport event is fired, update the Meteor Session
|
|
|
|
|
// with the viewport index that it was fired from.
|
2016-08-20 10:48:01 -03:00
|
|
|
Session.set('activeViewport', viewportIndex);
|
2015-12-09 15:48:24 +01:00
|
|
|
|
2016-11-03 15:15:03 -02:00
|
|
|
// Update the Session variable to the UI re-renders
|
|
|
|
|
Session.set('LayoutManagerUpdated', Random.id());
|
|
|
|
|
|
2015-12-09 15:48:24 +01:00
|
|
|
// Add the 'active' class to the parent container to highlight the active viewport
|
|
|
|
|
$('#imageViewerViewports .viewportContainer').removeClass('active');
|
2016-11-04 10:31:15 -02:00
|
|
|
jQueryElement.parents('.viewportContainer').addClass('active');
|
2015-12-09 15:48:24 +01:00
|
|
|
|
|
|
|
|
// Finally, enable stack prefetching and hide the reference lines from
|
2016-11-04 10:31:15 -02:00
|
|
|
// the newly activated viewport that has a canvas
|
|
|
|
|
|
|
|
|
|
if (jQueryElement.find('canvas').length) {
|
|
|
|
|
// Cornerstone Tools compare DOM elements (check getEnabledElement cornerstone function)
|
|
|
|
|
// so we can't pass a jQuery object as an argument, otherwise it throws an excepetion
|
|
|
|
|
const domElement = jQueryElement.get(0);
|
|
|
|
|
enablePrefetchOnElement(domElement);
|
|
|
|
|
displayReferenceLines(domElement);
|
|
|
|
|
}
|
2015-12-18 22:24:00 -05:00
|
|
|
|
|
|
|
|
// Set the div to focused, so keypress events are handled
|
2016-01-15 22:33:18 -05:00
|
|
|
//$(element).focus();
|
|
|
|
|
//.focus() event breaks in FF&IE
|
2016-11-04 10:31:15 -02:00
|
|
|
jQueryElement.triggerHandler('focus');
|
2016-08-20 10:48:01 -03:00
|
|
|
};
|