Skip to content

Commit c8a1ce1

Browse files
committed
feat(progressbar): Progress type can be set through attribute
closes angular-ui#1241
1 parent d7c69d4 commit c8a1ce1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/progressbar/docs/demo.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<h2>Static</h2>
33
<div class="row-fluid">
44
<div class="span4"><progress percent="55"></progress></div>
5-
<div class="span4"><progress percent="22" class="progress-warning progress-striped"></progress></div>
6-
<div class="span4"><progress percent="88" class="progress-danger progress-striped active"></div>
5+
<div class="span4"><progress percent="22" type="'warning'" class="progress-striped"></progress></div>
6+
<div class="span4"><progress percent="88" type="'danger'" class="progress-striped active"></div>
77
</div>
88

99
<h2>Dynamic <button class="btn btn-primary" type="button" ng-click="random()">Randomize</button></h2>

src/progressbar/progressbar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ angular.module('ui.bootstrap.progressbar', ['ui.bootstrap.transition'])
1414
var stackedTypes = angular.isDefined($attrs.stackedTypes) ? $scope.$eval('[' + $attrs.stackedTypes + ']') : progressConfig.stackedTypes;
1515

1616
// Create bar object
17-
this.makeBar = function(newBar, oldBar, index) {
17+
this.makeBar = function(newBar, oldBar, index, progressType) {
1818
var newValue = (angular.isObject(newBar)) ? newBar.value : (newBar || 0);
1919
var oldValue = (angular.isObject(oldBar)) ? oldBar.value : (oldBar || 0);
20-
var type = (angular.isObject(newBar) && angular.isDefined(newBar.type)) ? newBar.type : (autoType) ? getStackedType(index || 0) : null;
20+
var type = (angular.isObject(newBar) && angular.isDefined(newBar.type)) ? newBar.type : angular.isDefined(progressType) ? progressType : (autoType) ? getStackedType(index || 0) : null;
2121

2222
return {
2323
from: oldValue,
@@ -65,7 +65,7 @@ angular.module('ui.bootstrap.progressbar', ['ui.bootstrap.transition'])
6565
}
6666
} else {
6767
// Simple bar
68-
controller.addBar(controller.makeBar(newValue, oldValue));
68+
controller.addBar(controller.makeBar(newValue, oldValue, 0, scope.$eval(attrs.type)));
6969
}
7070
}, true);
7171

0 commit comments

Comments
 (0)