bootstrap-progressbar
is a jQuery plugin which extends the basic twitter-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.
- Add bootstrap 3.1.1 styles
- Switch to Gulp
- Remove bs dotfiles
- Fix #30 compile errors with old markup
- Fix #29 wrong style generation
- Fix #28 element creation which will brick with
django-compressor
Note: this version sets (fixes) some vertical styles which may affect (or brick) your styles. Please checkout the css or less before updating.
- Download the latest release: v0.7.1
- Clone the repository:
git clone git@github.com:minddust/bootstrap-progressbar.git
- Install with Bower:
bower install bootstrap-progressbar
-
include
bootstrap-progressbar.js
<script type="text/javascript" src="bootstrap-progressbar.js"></script>
-
activate
bootstrap-progressbar
functionality on progressbars of your choice:$('.progress .bar').progressbar(); // bootstrap 2 $('.progress .progress-bar').progressbar(); // bootstrap 3
-
set the
aria
attribute and remove thewidth
style attribute (alternatively you can set it to 0)-
aria-valuetransitiongoal
<div class="progress"> <div class="progress-bar" aria-valuetransitiongoal="75"></div> </div>
-
aria-valuemin
(default: 0) andaria-valuemax
(default: 100)<div class="progress"> <div class="progress-bar" aria-valuetransitiongoal="75" aria-valuemin="-1337" aria-valuemax="9000"></div> </div>
-
-
Do I need the additional style file?
-
for the horizontal bar with no or filled text: NO
-
for any vertical bars or the horizontal bar with centered text or right aligned bar: YES
less:
<link rel="stylesheet/less" type="text/css" href="bootstrap-progressbar.less">
css:
<link rel="stylesheet" type="text/css" href="bootstrap-progressbar.css">
you can find your needed css or less file inside the css or less folder.
-
-
Multiple trigger
You can trigger progressbar as much as you want. Just change your
aria
attribute(s) and trigger.progressbar()
again. All settings made before will be kept.
Progressbar.defaults = {
transition_delay: 300,
refresh_speed: 50,
display_text: 'none',
use_percentage: true,
percent_format: function(percent) { return percent + '%'; },
amount_format: function(amount_part, amount_total) { return amount_part + ' / ' + amount_total; },
update: $.noop,
done: $.noop,
fail: $.noop
};
Is the time in milliseconds until the animation starts.
This could be useful to delay the start on the initial page load like:
$(document).ready(function() {
$('.progress .progress-bar').progressbar({
transition_delay: 1500
});
});
Is the time in milliseconds which will elapse between every text refresh, aria-valuenow
attribute update and update
callback call.
Determines if and where to display text on the progressbar. Possible options:
none
no textfill
text on filled barcenter
text on center (this mode changes css / html due to styling requirements)
If text will be displayed - this option determines whether to show the percentage value or the amount.
So if use_percentage
is false and aria-valuemin
and aria-valuemax
are not set (or to 0
and 100
) the value will be the same but amount_format
will be used to format the result.
Example:
<div class="progress-bar" aria-valuetransitiongoal="75">
with use_percentage: true
is the final text: 75%
with use_percentage: false
is the final text: 75 / 100
Is a function which returns the text format for progressbar with use_percentage: true
.
It takes 1 argument which is the current percent value.
Is a function which returns the text format for progressbar with use_percentage: false
.
It takes 2 argument which are the current and total amount.
Is a callback function which will be called while the progressbar is transitioning ;)
Depends on refresh_speed
.
It takes 1 argument which is the current percent value.
Is a callback function which will be called when the transition process is done.
Is a callback function which will be called when an error occurs.
It takes 1 argument which is the error message.
-
to use a horizontal progressbar which is align to the right you have to add
right
to theprogress
element.<div class="progress right">
-
to use a vertical progressbar you have to add
vertical
to theprogress
element.<div class="progress vertical">
-
to use a vertical progressbar which is align to the bottom you have to add
vertical
andbottom
to theprogress
element.<div class="progress vertical bottom">
to change the animation itself you have to overwrite either less or css
-
horizontal
-
less
.progress .bar { .transition(width 2s ease-in-out); }
-
css
.progress .bar { -webkit-transition: width 2s ease-in-out; -moz-transition: width 2s ease-in-out; -ms-transition: width 2s ease-in-out; -o-transition: width 2s ease-in-out; transition: width 2s ease-in-out; }
-
-
vertical
-
less
.progress.vertical .bar { .transition(height 2s ease-in-out); }
-
css
.progress.vertical .bar { -webkit-transition: height 2s ease-in-out; -moz-transition: height 2s ease-in-out; -ms-transition: height 2s ease-in-out; -o-transition: height 2s ease-in-out; transition: height 2s ease-in-out; }
-
- Looks like iOS Safari is flooring the width of the transition. So if you want to display text with a correct value you have to use a full bar width greater or equal 100px.
Copyright 2013-2014 Stephan Groß, under MIT license.
Want to appreciate my work? minddust at Gittip