Skip to content

Commit 02f15e8

Browse files
committed
Allow for the user to set the wizard height as an optional property
1 parent f9f1932 commit 02f15e8

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

src/wizard/wizard-directive.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* @param {boolean=} wizardDone Value that is set when the wizard is done
3333
* @param {string} loadingWizardTitle The text displayed when the wizard is loading
3434
* @param {string=} loadingSecondaryInformation Secondary descriptive information to display when the wizard is loading
35-
* @param {number=} minHeight The minimum height the wizard should adjust to if the window height is decreased. The wizard height is adjusted with the window resize event and this sets the minimum.
35+
* @param {number=} wizardHeight The height the wizard should be set to. If this is not set, the wizard height is adjusted with the window resize event.
3636
*
3737
* @example
3838
<example module="patternfly.wizard" deps="patternfly.form">
@@ -314,7 +314,7 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
314314
wizardDone: '=?',
315315
loadingWizardTitle: '=?',
316316
loadingSecondaryInformation: '=?',
317-
minHeight: '=?'
317+
wizardHeight: '=?'
318318
},
319319
templateUrl: 'wizard/wizard.html',
320320
controller: function ($scope, $timeout) {
@@ -660,23 +660,23 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
660660
};
661661
},
662662
link: function ($scope, $element, $attrs) {
663-
// watching isOpen attribute to display modal when needed
664-
var isOpenListener = $scope.$watch('isOpen', function (newVal, oldVal) {
665-
if (newVal === true) {
666-
$scope.openModal();
667-
}
668-
});
663+
var INDICATOR_HEIGHT = 131,
664+
FOOTER_HEIGHT = 58,
665+
HEADER_HEIGHT = 41,
666+
WINDOW_SPACING = 70;
669667

670-
if (!$scope.minHeight) {
671-
$scope.minHeight = 400;
672-
}
668+
var minimumHeight = !$scope.hideIndicators ? INDICATOR_HEIGHT + HEADER_HEIGHT + FOOTER_HEIGHT : HEADER_HEIGHT + FOOTER_HEIGHT;
673669

674-
if ($window.innerHeight > $scope.minHeight) {
675-
$element.height($window.innerHeight - 70);
670+
// user has specified the height
671+
if ($scope.wizardHeight) {
672+
$element.height($scope.wizardHeight);
676673
} else {
677-
$element.height($scope.minHeight);
674+
if ($window.innerHeight - WINDOW_SPACING > minimumHeight) {
675+
$element.height($window.innerHeight - WINDOW_SPACING);
676+
} else {
677+
$element.height(minimumHeight);
678+
}
678679
}
679-
$scope.$on('$destroy', isOpenListener);
680680

681681
$scope.$watch('wizardReady', function () {
682682
if ($scope.wizardReady) {
@@ -685,8 +685,8 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
685685
});
686686

687687
angular.element($window).bind('resize', function () {
688-
if ($window.innerHeight > $scope.minHeight) {
689-
$element.height($window.innerHeight - 70);
688+
if ($window.innerHeight - WINDOW_SPACING > minimumHeight && !$scope.wizardHeight) {
689+
$element.height($window.innerHeight - WINDOW_SPACING);
690690
}
691691
});
692692
}

src/wizard/wizard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h3 class="blank-slate-pf-main-action">{{loadingWizardTitle}}</h3>
2323
<p class="blank-slate-pf-secondary-action">{{loadingSecondaryInformation}}</p>
2424
</div>
2525
</div>
26-
<div class="wizard-pf-row" ng-transclude></div>
26+
<div class="wizard-pf-row" ng-class="{'wizard-pf-row-adjustable': hideIndicators}" ng-transclude></div>
2727
</div>
2828
<div class="modal-footer wizard-pf-footer">
2929
<button pf-wiz-cancel class="btn btn-default btn-cancel wizard-pf-cancel" ng-disabled="wizardDone" ng-click="onCancel()">{{cancelTitle}}</button>

styles/angular-patternfly.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,7 @@ accordion > .panel-group .panel-open .panel-title > a:before {
443443
.wizard-pf-singlestep {
444444
margin-left: 0;
445445
}
446+
447+
.wizard-pf-row-adjustable {
448+
top: 41px;
449+
}

0 commit comments

Comments
 (0)