====
.directive('modalbody', function ($timeout) { // 填滿可用空間
return {
link: function (scope, elem, attrs) {
var positioner = function () {
$(elem).closest('.modal-content').css('height', $(window).height() - 60);
$(elem).closest('.modal-dialog').css('width', $(window).width() - 60);
var h = $(elem).closest('.modal-content')[0].offsetHeight - $(elem).closest('.modal-content').find('.modal-header')[0].offsetHeight- $(elem).closest('.modal-content').find('.modal-footer')[0].offsetHeight;
if (attrs.modalbody) h += parseFloat(attrs.modalbody);
$(elem).outerHeight(h);
$(elem).find('.modal-body-inner').height($(elem).height());
}
$(window).resize(function () {
positioner();
});
$timeout(function () {
positioner();
});
}
};
})
.directive('modalbodymax', function ($timeout) { // 超過最大可用空間才限制
return {
link: function (scope, elem, attrs) {
var positioner = function () {
$(elem).closest('.modal-content').css('maxHeight', $(window).height() - 60);
$(elem).closest('.modal-content').css('maxWidth', $(window).width() - 60);
var maxh = $(window).height() - 60 * 2 - $(elem).closest('.modal-content').find('.modal-header').height() - $(elem).closest('.modal-content').find('.modal-footer').height();
$(elem).css('maxHeight', maxh);
}
$(window).resize(function () {
positioner();
});
$timeout(function () {
positioner();
});
}
};
})
html
====
<script type="text/ng-template" id="voucher.html">
<div class="modal-header "> <button class="close" ng-click="close()"><span class='glyphicon glyphicon-remove' style="font-size:40px"></span></button> <h3 class="modal-title">傳票明細</h3> </div>
<div class="modal-body" modalbody> <div ag-grid="gridOptions" class="ag-green modal-body-inner">
</div>
</div>
</script>
css
====
.modal-body-inner {
overflow-y: auto;
}
css
====
.modal-body-inner {
overflow-y: auto;
}
沒有留言:
張貼留言