ohif-viewer/Packages/viewerbase/client/components/viewer/gridLayout/gridLayout.js

48 lines
1.5 KiB
JavaScript
Raw Normal View History

import { OHIF } from 'meteor/ohif:core';
2016-08-22 19:54:31 +02:00
import { Template } from 'meteor/templating';
Template.gridLayout.helpers({
2016-08-22 19:54:31 +02:00
// Get the height percentage for each viewport
height() {
const instance = Template.instance();
const rows = instance.data.rows || 1;
return 100 / rows;
},
2016-08-22 19:54:31 +02:00
// Get the width percentage for each viewport
width() {
const instance = Template.instance();
const columns = instance.data.columns || 1;
return 100 / columns;
},
2016-08-22 19:54:31 +02:00
// Return the viewports list
viewports() {
const instance = Template.instance();
const rows = instance.data.rows;
const columns = instance.data.columns;
const numViewports = rows * columns;
const viewportData = instance.data.viewportData;
const numViewportsWithData = viewportData.length;
// Check if the viewportData length is different from the given
if (numViewportsWithData < numViewports) {
2016-08-22 19:54:31 +02:00
// Add the missing viewports
var difference = numViewports - numViewportsWithData;
for (var i = 0; i < difference; i++) {
viewportData.push({
viewportIndex: numViewportsWithData + i + 1,
2016-08-22 19:54:31 +02:00
rows,
columns
});
}
} else if (numViewportsWithData > numViewports) {
2016-08-22 19:54:31 +02:00
// Remove the additional viewports
return viewportData.slice(0, numViewports);
}
2016-08-22 19:54:31 +02:00
// Return the viewports
return viewportData;
}
2016-08-22 19:54:31 +02:00
});