ohif-viewer/Packages/ohif-study-list/client/components/tabTitle/tabTitle.js
Erik Ziegler ab4d4c9008 Work on refactoring measurements out of Lesion Tracker package
- Removed AssociatedStudies Collection
- Measurement API is generated from configuration files
- Data exchange methods are defined in configuration
2016-11-15 08:21:46 +01:00

42 lines
1.7 KiB
JavaScript

Template.tabTitle.events({
/**
* Closes a tab when the close button is pressed in the title
* The next tab to the left is loaded if the current tab is closed
*
* @param e The click event used to close the tab
*/
'click .close': function(e) {
console.log('click .close');
// Identify the tab title DOM node
var tab = $(e.currentTarget).parents('a[data-toggle="tab"]').eq(0);
// Get the relevent contentId that this tab title represents
// Replace any hash marks (#) that were required by Bootstrap's tab switching
var contentId = tab.data('target').replace('#', '');
// Check if we are closing the active tab. If we are, prepare to switch
// to the next tab to the left.
var activeContentId = Session.get('activeContentId');
if (activeContentId === contentId) {
// Find the index of the tab that is being closed
var tabIndex = tab.parent('li').index();
// Find the index the tab to its left
var newActiveTabIndex = Math.max(tabIndex - 1, 0);
// Find the DOM node of the tab that will be activated
var newActiveTab = $('.tabTitle').eq(newActiveTabIndex);
// Find the content ID of the tab that will be switched to
var newActiveTabLink = newActiveTab.find('a[data-toggle=tab]');
var newContentId = newActiveTabLink.data('target').replace('#', '');
// Switch to this tab
switchToTab(newContentId);
}
// Remove any stored data related to this tab from the global ViewerData structure
delete ViewerData[contentId];
}
});