Files
awx/awx/ui/static/js/directives/auto-size-module.js
2015-02-06 12:49:04 -05:00

40 lines
1.1 KiB
JavaScript

export default
[ '$window',
AutoSizeModule
];
function AutoSizeModule($window) {
// Adjusts the size of the module so that all modules
// fit into a single a page; assumes there are 2 rows
// of modules, with the available height being offset
// by the navbar & the count summaries module
return function(scope, element) {
function adjustSizeInitially() {
adjustSize();
}
function adjustSize() {
var winHeight = $($window).height(),
available_height = winHeight - $('#main-menu-container .navbar').outerHeight() - $('#count-container').outerHeight() - 120;
element.height(available_height/2);
}
$($window).resize(adjustSize);
element.on('$destroy', function() {
$($window).off('resize', adjustSize);
});
// This makes sure count-container div is loaded
// by controllers/Home.js before we use it
// to determine the available window height
scope.$on('dashboardReady', function() {
adjustSizeInitially();
});
};
}