Repository navigation
Expand file tree
/
Copy pathModalBody.js
More file actions
46 lines (40 loc) · 1.91 KB
/
Copy pathModalBody.js
File metadata and controls
46 lines (40 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Simple directive to change bootstrap modal body max-height value to be maximum that
* users browser can show. Directive itself is fairly straight forward, it just attach
* itself to bootstrap model content body class (modal-body). Directive attach window
* resize event to update max-height value of modal body.
*/
(function() {
'use strict';
angular.module('Taskboard.directives')
.directive('modalBody',
[
'$timeout',
function($timeout) {
return {
restrict: 'C',
link: function(scope, element) {
// Determine reserved header and footer elements
var header = angular.element('header .navbar');
var footer = angular.element('footer .navbar');
// Helper function to attach new modal-body max-height CSS property
var resize = function() {
var totalHeight = angular.element(document).height() - header.height() - footer.height() - 70;
angular.element(element).css('max-height', totalHeight + 'px');
};
// Make new resize of modal-body whenever user changes browser window size
angular.element(window).resize(function() {
$timeout(resize);
});
// Resize again whenever 'resizeModal' event is broadcast
scope.$on('resizeModal', function() {
$timeout(resize);
});
// And in init resize modal
resize();
}
};
}
]
);
}());