Brad
Brad

Reputation: 272

modal-content not setting height to contain content

I'm trying to learn Angular and modals just aren't working. The modal will show up, but the modal-content div isn't growing to contain all of the content. Instead, the content just runs out of the bottom of a very short modal. See picture below for what it is doing: Bad Modal

The three mini-paragraphs and the links below are supposed to be inside the modal.

Here is the controller for the "login" page:

MyApp.controller('loginController', ['$scope', '$location', '$translate', '$http', 'browserCheckService', 'modalService', function ($scope, $location, $translate, $http, browserCheckService, modalService) {
    'use strict';
    $scope.checkBrowser = function() {
        if (browserCheckService.browserCheck() === false) {
            try {
                var settings = {
                    title: 'Incompatible Browser Warning',
                    size: 'lg',
                    templateUrl: 'Pages/browserReject.html',
                    controller: 'browserRejectController'
                }
                modalService.DisplayModal(settings);
            } catch (err) {
                alert(err.message);
            }
        }
    };
    $scope.checkBrowser();
}]);

Here is the controller for the browserReject:

MyApp.controller('browserRejectController', ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) {
    'use strict';
    $scope.close = function () {
        $uibModalInstance.dismiss();
    }
}]);

Here is the modalService:

angular.module('MyApp').service('modalService', ['$uibModal', function ($uibModal) {
    'use strict';
    this.DisplayModal = function (settings) {
        if (settings === undefined) {
            throw "Settings must be supplied for modal";
        } else {
            var modalInstance = $uibModal.open({
                animation: true,
                templateUrl: settings.templateUrl,
                controller: settings.controller,
                size: settings.size
            });
        }
    };
}]);

The browserCheckService is simply set to return to false so I could test the modal.

Here is the browserReject.html contents:

<div id="modalHeaderContainer">
    <div id="title">Incompatible Browser Warning</div>
    <div id="closeButton">
        <button type="submit" class="close" ng-click="close()">X</button>
    </div>
</div>
<hr />
<div id="jr_outer">
    <div id=jr_inner">
        <div id="jr_center">
            <p translate={{'application__browser_reject_message'}}"></p>
            <ul>
                <li>
                    <a target="_blank" href="http://www.google.com/chrome/>Google Chrome</a>
                </li>
                <li>
                    <a target="_blank" href="https://www.mozilla.org/en-US/firefox/new/>Firefox</a>
                </li>
                <li>
                    <a target="_blank" href="http://www.apple.com/safari/>Safari</a>
                </li>
                <li>
                    <a target="_blank" href="http://windows.microsoft.com/en-us/internet-explorer/download-ie">Internet Explorer</a>
                </li>
            </ul>
        </div>
    </div>
</div>

Here is my CSS as it currently stands for the modal:

/* CSS for modal settings */
.ng-modal-overlay {
    /* A dark translucent div that covers the whole screen */
    position:absolute;
    z-index:9999;
    top:0;
    left:0;
    width:100%;
    height:100%;
    background-color:#000000;
    opacity: 0.8;
}
.ng-modal-dialog {
    /* A centered div above the overlay with a box shadow. */
    z-index:10000;
    position: absolute;
    width: 50%; /* Default */

    /* Center the dialog */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
    -moz-transform: translate(-50%, -50%);

    background-color: #fff;
    box-shadow: 4px 4px 80px #000;
}
.ng-modal-dialog-content {
    padding:10px;
    text-align: left;
}
.ng-modal-close {
    position: absolute;
    top: 3px;
    right: 5px;
    padding: 5px;
    cursor: pointer;
    font-size: 120%;
    display: inline-block;
    font-weight: bold;
    font-family: 'arial', 'sans-serif';
}

#modalHeaderContainer {
    width:100%;
    height: 1.5em;
}

#title {
    float:left;
    font-size:1.7em;
    padding-left:.5em;
}

#closeButton {
    float:right;
    padding-top:.5em;
    padding-right:.5em;
}
/* End CSS for modal settings */

I've read the posts here and here, as well as several others and nothing seems to quite fit. I feel as though I'm overlooking something exceedingly simple, but can't find it. I've tried setting max-height on modal-content to 100%, but that doesn't change the display, either.

Upvotes: 1

Views: 7574

Answers (2)

Mike Mason
Mike Mason

Reputation: 3

Not exactly a fit but people looking for answers to uibmodal css overflow questions will need this:

Believe it or not, if you do not set your overflow:hidden or overflow:scroll on anything dynamic that you set a height to, like a repeater in angular, or injected content in jquery the content will simply look as if the modal isn't stretching, when in fact it is doing exactly as intended.

Upvotes: 0

razblack
razblack

Reputation: 131

you should override the default .modal-window by doing something like the following in your css:

.mynewModal-modal-window .modal-window {
  width: 100%;
  height: 100%;
}

and add its' class as a parameter to the open method of $uibModal:

this.DisplayModal = function (settings) {
    if (settings === undefined) {
        throw "Settings must be supplied for modal";
    } else {
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: settings.templateUrl,
            controller: settings.controller,
            windowClass: 'myNewModal-modal-window',
            size: settings.size
        });
    }
};

I just haven't found a way to override the modal-content yet via the controller :( (would be nice to have something similar)

Upvotes: 2

Related Questions