2016-11-04 13:31:15 +01:00
|
|
|
setActiveViewport = element => {
|
2015-12-09 15:48:24 +01:00
|
|
|
if (!element) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 13:31:15 +01: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 15:48:01 +02:00
|
|
|
Session.set('activeViewport', viewportIndex);
|
2015-12-09 15:48:24 +01:00
|
|
|
|
2016-11-03 18:15:03 +01: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 13:31:15 +01: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 13:31:15 +01: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-19 04:24:00 +01:00
|
|
|
|
|
|
|
|
// Set the div to focused, so keypress events are handled
|
2016-01-16 04:33:18 +01:00
|
|
|
//$(element).focus();
|
|
|
|
|
//.focus() event breaks in FF&IE
|
2016-11-04 13:31:15 +01:00
|
|
|
jQueryElement.triggerHandler('focus');
|
2016-08-20 15:48:01 +02:00
|
|
|
};
|