Skip to content

Commit 8e5ea0e

Browse files
committed
Modify wizard height calculation to use adjustable contentheight property instead of growing to the window height.
1 parent 02f15e8 commit 8e5ea0e

File tree

5 files changed

+27
-38
lines changed

5 files changed

+27
-38
lines changed

src/wizard/wizard-directive.js

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
* @param {string=} cancelTitle The text to display on the cancel button
2525
* @param {string=} backTitle The text to display on the back button
2626
* @param {string=} nextTitle The text to display on the next button
27-
* @param {function (step)=} backCallback Called to notify when the back button is clicked
28-
* @param {function (step)=} nextCallback Called to notify when the next button is clicked
29-
* @param {function ()=} onFinish Called to notify when when the wizard is complete. Returns a boolean value to indicate if the finish operation is complete
30-
* @param {function ()=} onCancel Called when the wizard is canceled, returns a boolean value to indicate if cancel is successful
27+
* @param {function(step)=} backCallback Called to notify when the back button is clicked
28+
* @param {function(step)=} nextCallback Called to notify when the next button is clicked
29+
* @param {function()=} onFinish Called to notify when when the wizard is complete. Returns a boolean value to indicate if the finish operation is complete
30+
* @param {function()=} onCancel Called when the wizard is canceled, returns a boolean value to indicate if cancel is successful
3131
* @param {boolean} wizardReady Value that is set when the wizard is ready
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=} wizardHeight The height the wizard should be set to. If this is not set, the wizard height is adjusted with the window resize event.
35+
* @param {string=} contentHeight The height the wizard content should be set to. This defaults to 300px if the property is not supplied.
3636
*
3737
* @example
3838
<example module="patternfly.wizard" deps="patternfly.form">
@@ -50,6 +50,7 @@
5050
next-callback="nextCallback"
5151
back-callback="backCallback"
5252
wizard-done="deployComplete || deployInProgress"
53+
content-height="'600px'"
5354
loading-secondary-information="secondaryLoadInformation">
5455
<div pf-wizard-step step-title="First Step" substeps="true" step-id="details" step-priority="0" show-review="true" show-review-details="true">
5556
<div ng-include="'detail-page.html'">
@@ -67,6 +68,7 @@
6768
</div>
6869
<div pf-wizard-step step-title="Second Step" substeps="false" step-id="configuration" step-priority="1" show-review="true" review-template="review-second-template.html" >
6970
<form class="form-horizontal">
71+
<h3>Wizards should make use of substeps consistently throughout (either using them or not using them). This is an example only.</h3>
7072
<div pf-form-group pf-label="Lorem">
7173
<input id="new-lorem" name="lorem" ng-model="data.lorem" type="text"/>
7274
</div>
@@ -314,7 +316,7 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
314316
wizardDone: '=?',
315317
loadingWizardTitle: '=?',
316318
loadingSecondaryInformation: '=?',
317-
wizardHeight: '=?'
319+
contentHeight: '=?'
318320
},
319321
templateUrl: 'wizard/wizard.html',
320322
controller: function ($scope, $timeout) {
@@ -389,6 +391,17 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
389391
$scope.wizardReady = true;
390392
}
391393

394+
if (angular.isUndefined($scope.contentHeight)) {
395+
$scope.contentHeight = '300px';
396+
}
397+
this.contentHeight = $scope.contentHeight;
398+
$scope.contentStyle = {
399+
'height': $scope.contentHeight,
400+
'max-height': $scope.contentHeight,
401+
'overflow-y': 'auto'
402+
};
403+
this.contentStyle = $scope.contentStyle;
404+
392405
$scope.nextEnabled = false;
393406
$scope.prevEnabled = false;
394407

@@ -659,36 +672,12 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
659672
this.goTo(0);
660673
};
661674
},
662-
link: function ($scope, $element, $attrs) {
663-
var INDICATOR_HEIGHT = 131,
664-
FOOTER_HEIGHT = 58,
665-
HEADER_HEIGHT = 41,
666-
WINDOW_SPACING = 70;
667-
668-
var minimumHeight = !$scope.hideIndicators ? INDICATOR_HEIGHT + HEADER_HEIGHT + FOOTER_HEIGHT : HEADER_HEIGHT + FOOTER_HEIGHT;
669-
670-
// user has specified the height
671-
if ($scope.wizardHeight) {
672-
$element.height($scope.wizardHeight);
673-
} else {
674-
if ($window.innerHeight - WINDOW_SPACING > minimumHeight) {
675-
$element.height($window.innerHeight - WINDOW_SPACING);
676-
} else {
677-
$element.height(minimumHeight);
678-
}
679-
}
680-
675+
link: function ($scope) {
681676
$scope.$watch('wizardReady', function () {
682677
if ($scope.wizardReady) {
683678
$scope.goTo($scope.getEnabledSteps()[0]);
684679
}
685680
});
686-
687-
angular.element($window).bind('resize', function () {
688-
if ($window.innerHeight - WINDOW_SPACING > minimumHeight && !$scope.wizardHeight) {
689-
$element.height($window.innerHeight - WINDOW_SPACING);
690-
}
691-
});
692681
}
693682
};
694683
});

src/wizard/wizard-step-directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ angular.module('patternfly.wizard').directive('pfWizardStep', function () {
392392
$scope.pageNumber = wizard.getStepNumber($scope);
393393
});
394394
$scope.title = $scope.stepTitle;
395-
395+
$scope.contentStyle = wizard.contentStyle;
396396
wizard.addStep($scope);
397397
$scope.wizard = wizard;
398398
}

src/wizard/wizard-step.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<section ng-show="selected" ng-class="{current: selected, done: completed}">
2-
<div class="wizard-pf-sidebar" ng-style="substepsListStyle" ng-if="substeps === true">
2+
<div class="wizard-pf-sidebar" ng-style="contentStyle" ng-if="substeps === true">
33
<ul class="list-group">
44
<li class="list-group-item" ng-class="{active: step.selected}" ng-repeat="step in getEnabledSteps()">
55
<a ng-click="stepClick(step)">
@@ -9,7 +9,7 @@
99
</li>
1010
</ul>
1111
</div>
12-
<div class="wizard-pf-main" ng-class="{'wizard-pf-singlestep': !substeps}">
12+
<div class="wizard-pf-main" ng-class="{'wizard-pf-singlestep': !substeps}" ng-style="contentStyle">
1313
<div class="wizard-pf-contents" ng-transclude></div>
1414
</div>
1515
</section>

src/wizard/wizard.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ <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-class="{'wizard-pf-row-adjustable': hideIndicators}" ng-transclude></div>
26+
<div class="wizard-pf-position-override" ng-transclude ></div>
2727
</div>
28-
<div class="modal-footer wizard-pf-footer">
28+
<div class="modal-footer wizard-pf-footer wizard-pf-position-override">
2929
<button pf-wiz-cancel class="btn btn-default btn-cancel wizard-pf-cancel" ng-disabled="wizardDone" ng-click="onCancel()">{{cancelTitle}}</button>
3030
<div class="tooltip-wrapper" tooltip="{{prevTooltip}}" tooltip-placement="left">
3131
<button id="backButton" pf-wiz-previous class="btn btn-default" ng-disabled="!wizardReady || wizardDone || !prevEnabled || firstStep"

styles/angular-patternfly.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,6 @@ accordion > .panel-group .panel-open .panel-title > a:before {
444444
margin-left: 0;
445445
}
446446

447-
.wizard-pf-row-adjustable {
448-
top: 41px;
447+
.wizard-pf-position-override {
448+
position: relative;
449449
}

0 commit comments

Comments
 (0)