Skip to content

Commit e7cdb59

Browse files
committed
Update to progressbar 0.8.2
1 parent 676994e commit e7cdb59

File tree

4 files changed

+86
-3
lines changed

4 files changed

+86
-3
lines changed

_includes/bootstrap_progressbar_demo_content_2.html

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,84 @@ <h4>callbacks <button type="button" class="btn btn-primary" id="m-callback-start
4545

4646
<div style="height: 40px">&nbsp;</div>
4747

48+
<a name="m-callback-this"></a>
49+
<h4>callbacks <button type="button" class="btn btn-primary" id="m-callback-this-start">start</button> <button type="button" class="btn btn-danger" id="m-callback-this-reset">reset</button></h4>
50+
51+
<div class="bs-example m-callback-this">
52+
<div class="{{ bs_pro_def }}"><div class="{{ bs_bar_def }} six-sec-ease-in-out" role="progressbar" data-transitiongoal-backup="100"></div></div>
53+
<script type='text/javascript'>
54+
$(document).ready(function() {
55+
// thanks:
56+
// http://stackoverflow.com/questions/5833624/increase-css-brightness-color-on-click-with-jquery-javascript
57+
// http://jsfiddle.net/K8cMX/7/
58+
function HsvToRgb(h, s, v) {
59+
h = h / 360;
60+
s = s / 100;
61+
v = v / 100;
62+
63+
if (s == 0)
64+
{
65+
var val = Math.round(v * 255);
66+
return {r:val,g:val,b:val};
67+
}
68+
hPos = h * 6;
69+
hPosBase = Math.floor(hPos);
70+
base1 = v * (1 - s);
71+
base2 = v * (1 - s * (hPos - hPosBase));
72+
base3 = v * (1 - s * (1 - (hPos - hPosBase)));
73+
if (hPosBase == 0) {red = v; green = base3; blue = base1}
74+
else if (hPosBase == 1) {red = base2; green = v; blue = base1}
75+
else if (hPosBase == 2) {red = base1; green = v; blue = base3}
76+
else if (hPosBase == 3) {red = base1; green = base2; blue = v}
77+
else if (hPosBase == 4) {red = base3; green = base1; blue = v}
78+
else {red = v; green = base1; blue = base2};
79+
80+
red = Math.round(red * 255);
81+
green = Math.round(green * 255);
82+
blue = Math.round(blue * 255);
83+
return {r:red,g:green,b:blue};
84+
}
85+
$('#m-callback-this-start').click(function() {
86+
var $pb = $('.m-callback-this .{{ bs_bar_def }}');
87+
$pb.attr('data-transitiongoal', $pb.attr('data-transitiongoal-backup'));
88+
$pb.progressbar({
89+
update: function(current_percentage, $this) {
90+
var color_helper = Math.round(current_percentage * 1.2); // red to green == 0 to 120 degree
91+
var colors = HsvToRgb(color_helper, 100, 100);
92+
$this.parent().parent().css('background-color', 'rgb(' + colors['r'] + ', ' + colors['g'] + ', ' + colors['b'] + ')');
93+
}
94+
});
95+
});
96+
$('#m-callback-this-reset').click(function() {
97+
$('.m-callback-this .{{ bs_bar_def }}').attr('data-transitiongoal', 0).progressbar();
98+
});
99+
});
100+
</script>
101+
</div>
102+
{% highlight html %}
103+
.six-sec-ease-in-out {
104+
-webkit-transition: width 6s ease-in-out;
105+
-moz-transition: width 6s ease-in-out;
106+
-ms-transition: width 6s ease-in-out;
107+
-o-transition: width 6s ease-in-out;
108+
transition: width 6s ease-in-out;
109+
}
110+
111+
<div class="{{ bs_pro_def }}">
112+
<div class="{{ bs_bar_def }} six-sec-ease-in-out" role="progressbar" data-transitiongoal="100"></div>
113+
</div>
114+
115+
$(document).ready(function() {
116+
$('.{{ bs_pro_def }} .{{ bs_bar_def }}').progressbar({
117+
update: function(current_percentage, $this) {
118+
$this.parent().parent().css('background-color', 'rgb(' + Math.round(current_percentage / 100 * 255) + ', 0, 0)');
119+
}
120+
});
121+
});
122+
{% endhighlight %}
123+
124+
<div style="height: 40px">&nbsp;</div>
125+
48126

49127
<a name="m-error"></a>
50128
<h4>error <button type="button" class="btn btn-primary" id="m-error-start">start</button></h4>

project/bootstrap-progressbar/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ project: bootstrap-progressbar
55
permalink: changelog/
66
---
77

8+
## 0.8.2 (2014-08-02)
9+
10+
* Fix #33 pass `$this` to `update` and `done` callback
11+
812
## 0.8.1 (2014-08-01)
913

1014
* Fix #35 wrong amount calculation for `aria-valuemin` != 0

project/bootstrap-progressbar/demo/js/bootstrap-progressbar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
if (current_percentage >= percentage) {
110110
current_percentage = percentage;
111111
current_value = data_transitiongoal;
112-
done();
112+
done($this);
113113
clearInterval(progress);
114114
}
115115

@@ -126,7 +126,7 @@
126126
}
127127
$this.attr('aria-valuenow', current_value);
128128

129-
update(current_percentage);
129+
update(current_percentage, $this);
130130
}, options.refresh_speed);
131131
}, options.transition_delay);
132132
};

project/bootstrap-progressbar/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ project: bootstrap-progressbar
99
`bootstrap-progressbar` is a [jQuery](http://jquery.com) plugin which extends the basic [twitter-bootstrap](https://github.com/twbs/bootstrap) progressbar. It provides the ability to animate the progressbar by adding Javascript in combination with the preexisting css transitions. Additionally you can display the current progress information in the bar or get the value via callback.
1010

1111

12-
## What's new in v0.8.1?
12+
## What's new in v0.8.2?
1313

1414
* Add bootstrap 3.2.0 styles
1515
* Extend `amount_format` hook for min value
1616
* Update demo page
1717
* Remove unused travis badge
1818
* Fix #27 switch `aria-valuetransitionsgoal` to `data-transitionsgoal`
1919
* Fix #35 wrong amount calculation for `aria-valuemin` != 0
20+
* Fix #33 pass `$this` to `update` and `done` callback
2021

2122
> __Note__: this version replaces the not official supported `aria-valuetransitionsgoal` with `data-transitionsgoal` which may affect (or brick) your progressbars.
2223

0 commit comments

Comments
 (0)