- Overview
- Documents
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.
Source: minddust.com
1. INCLUDE CSS AND JS FILES
<link rel="stylesheet" type="text/css" href="bootstrap/bootstrap-2.3.2.min.css"> <link rel="stylesheet" type="text/css" href="../css/bootstrap-progressbar-2.3.2.css"> <script type='text/javascript' src="jquery/jquery-1.8.3.min.js"></script> <script type='text/javascript' src="prettify/prettify.min.js"></script> <script type='text/javascript' src="bootstrap/bootstrap-2.3.2.min.js"></script> <script type="text/javascript" src="../bootstrap-progressbar.js"></script>
2. HTML
<div class="progress"> <div class="progress-bar" aria-valuetransitiongoal="75"></div> </div>
3. JAVASCRIPT
$('.progress .progress-bar').progressbar(); // bootstrap 3
4. OPTIONS
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 };
transition_delay
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 andupdate callback call.
Determines if and where to display text on the progressbar. Possible options:
- none no text
- fill text on filled bar
- center 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.