<script type="text/javascript" src="progressbar.js"></script> <link rel="stylesheet" type="text/css" href="progressbar.css" /> <div id="my_progress_bar"></div> <script type="text/javascript"> var config = { borderRadius: 10, width: 300, height: 20, imageUrl: 'images/h_fg2.png', }; var myProgressBar = new ProgressBar("my_progress_bar", config); </script>Look at the configuration object property list to find out how ProgressBar can be configured. Note, that some configuration properties and also ProgressBar properties are of integer type, but instead of simple integer value an enumeration is used for a better value description.
myProgressBar.setValue(50);
Name | Type | Default value |
animationInterval | Number (integer) | 100 |
Number of milliseconds between animation steps. | ||
animationSmoothness | ProgressBar.AnimationSmoothness | ProgressBar.AnimationSmoothness.None |
Indicates how progress between value A and value B is visualized. See usage example | ||
animationSpeed | Number (float) | 1.0 |
Animation speed factor (beside animationInterval). It's value should be set between 0.1 and 3. See usage example | ||
animationStyle | ProgressBar.AnimationStyle | ProgressBar.AnimationStyle.None |
Indicates animation style that is running on a progress bar. See usage example | ||
backgroundElement | HTMLDivElement | null |
HTML element that is used as a background. This property is accessible after progress bar was fully loaded (isLoaded is set to true). | ||
backgroundUrl | String | (empty string) |
An URL that points to a location of a progress bar background image. See usage example | ||
borderRadius | Number (integer) | 0 |
Determines progress bar edge rounding. See usage example | ||
creationType | ProgressBar.CreationType | ProgressBar.CreationType.Replace |
Determines how progress bar is created inside it's parent HTML element. Whether parent content is replaced with progress bar, or if progress bar is added at the end of a childNodes collection. See usage example | ||
direction | ProgressBar.Direction | ProgressBar.Direction.LeftToRight |
Determines progress direction. It could be from left to right or from right to left for horizontal orientation. For vertical orientation it coould be from top to bottom or from bottom to top. See usage example | ||
extraClassName | Object | (see extraClassName object) |
This object contains CSS class names for every HTML elements that progress bar consist of. See usage example | ||
height | Number (integer) | 20 |
Progress bar height (in pixels) | ||
image | Image | null |
An Image object that is used as a progress bar foreground. | ||
imageUrl | String | (empty string) |
An URL that points to a location of a progress bar foreground image. See usage example | ||
isLoaded | Boolean | false |
Indicates whether progress bar was fully loaded or not. | ||
labelText | String | (empty string) |
Sets custom text on a progress bar. This property may contain special tags like {value} and {progress} which are replaced with appropriate values. tag {value} - is replaced with current progress bar value, tag {value,0} - is replaced with current progress bar value, rounded to the nearest integer, tag {value,1} - is replaced with current progress bar value, rounded to the float number with 1 decimal digit, tag {value,N} - is replaced with current progress bar value, rounded to the float number with N decimal digits, tag {progress} - is replaced with percentage progress value, rounded to the nearest integer See usage example | ||
leftElement | HTMLDivElement | null |
HTML element that is used as a left part of a progress bar (or a top part in vertical orientation). This property is accessible after progress bar was fully loaded (isLoaded is set to true) and only when progress foreground image (passed during progress bar creation) width is less than whole progress bar width. Image height and progress bar height are taken in vertical orientation respectively. | ||
markerUrl | String | (empty string) |
An URL that points to a location of a progress bar marker image. This marker image is used with animations. It can also be set in CSS file provided with this Progress Bar solution. See usage example | ||
maxValue | Number | 100 |
Maximal value that the progress bar can have. | ||
middleElement | HTMLDivElement | null |
HTML element that is used as a middle part of a progress bar. This element is a wrapper for valueElement. This property is accessible after progress bar was fully loaded (isLoaded is set to true) and only when progress foreground image (passed during progress bar creation) width is less than whole progress bar width. Image height and progress bar height are taken in vertical orientation respectively. | ||
minValue | Number | 0 |
Minimal value that the progress bar can have. | ||
onAnimate | Function | null |
This function is called when progress bar is animated with interval defined in animationInterval. Note that animationStyle should be set. | ||
onAnimationStyleChanged | Function | null |
This function is called when animationStyle property has changed. | ||
onLoad | Function | null |
This function is called when progress bar was fully loaded. | ||
onValueChanged | Function | null |
This function is called when progress bar value has changed. | ||
orientation | ProgressBar.Orientation | ProgressBar.Orientation.Horizontal |
Determines the progress bar orientation. It can be horizontal or vertical. See usage example | ||
parentElement | HTMLElement | null |
HTML element that is used as a progress bar container. | ||
progress | Number (float) | 0.0 |
A number between 0.0 and 1.0 that indicated the current progress. | ||
progressPosition | Number (integer) | 0 |
Gets current progress shift in pixels, regarding progress bar width (in horizontal orientation) or height (in vertical orientation). This property could be used while extending progress bar with some extra HTML elements. See usage example | ||
rightElement | HTMLDivElement | null |
HTML element that is used as a right part of a progress bar (or a bottom part in vertical orientation). This property is accessible after progress bar was fully loaded (isLoaded is set to true) and only when progress foreground image (passed during progress bar creation) width is less than whole progress bar width. Image height and progress bar height are taken in vertical orientation respectively. | ||
showLabel | Boolean | true |
Determines whether label should be shown or not. | ||
textElement | HTMLDivElement | null |
HTML element that is used as a progress bar label for displaying current progress. | ||
value | Number | 0 |
Current progress value. | ||
valueElement | HTMLDivElement | null |
HTML element that is used as a progress indicator. It's contained inside middleElement. This property is accessible after progress bar was fully loaded (isLoaded is set to true) and only when progress foreground image (passed during progress bar creation) width is less than whole progress bar width. Image height and progress bar height are taken in vertical orientation respectively. | ||
width | Number (integer) | 300 |
Progress bar width (in pixels) | ||
wrapperElement | HTMLDivElement | null |
HTML element that is used as a progress indicator. It's contained directly inside parentElement. This property is accessible after progress bar was fully loaded (isLoaded is set to true) and only when progress foreground image (passed during progress bar creation) width is greater or equal the progress bar whole width. Image height and progress bar height are taken in vertical orientation respectively. |
Name | Parameters | Returns |
setAnimationStyle | ProgressBar.AnimationStyle newStyle | void |
Sets animation style for the ProgressBar object.
Example
myProgressBar.setAnimationStyle(ProgressBar.AnimationStyle.LeftToRight1);
| ||
setBackground | String url | void |
Sets new background image loaded from the given location.
Example
myProgressBar.setBackground('images/bg01.jpg');
| ||
setForeground | String url | void |
Sets new foreground image loaded from the given location.
Example
myProgressBar.setForeground('images/pb02.jpg');
See usage example
| ||
setMarkerImage | String url | void |
Sets new marker image loaded from the given location.
Example
myProgressBar.setMarkerImage('images/marker02.jpg');
| ||
setValue | Number newValue | void |
Sets progress bar new value. If newValue is less than minValue, then minValue is used as a new value. If value is greater than maxValue, then maxValue is used as a new value.
Example
myProgressBar.setValue(67);
|
Name | Type | Default value |
animationInterval | ||
animationSmoothness | ||
animationSpeed | ||
animationStyle | ||
backgroundUrl | ||
borderRadius | ||
creationType | ||
direction | ||
extraClassName | ||
height | ||
imageUrl | ||
labelText | ||
markerUrl | ||
maxValue | ||
minValue | ||
onAnimate | ||
onAnimationStyleChanged | ||
onLoad | ||
onValueChanged | ||
orientation | ||
showLabel | ||
width | ||
Name | Type | Default value |
background | String | (empty string) |
CSS class name for backgroundElement | ||
horizontalText | String | (empty string) |
CSS class name for textElement when progress bar is horizontally oriented. | ||
left | String | (empty string) |
CSS class name for leftElement | ||
marker | String | (empty string) |
CSS class name for markerElement | ||
middle | String | (empty string) |
CSS class name for middleElement | ||
parent | String | (empty string) |
CSS class name for parentElement | ||
right | String | (empty string) |
CSS class name for rightElement | ||
verticalText | String | (empty string) |
CSS class name for textElement when progress bar is vertically oriented. | ||
wrapper | String | (empty string) |
CSS class name for wrapperElement |
Name | Values |
ProgressBar.AnimationSmoothness |
None : 0, Smooth1 : 1, Smooth2 : 2, Smooth3 : 3, Smooth4 : 4, |
ProgressBar.AnimationStyle |
None : 0, Static : 1, StaticFull : 2, Custom : 3, CustomFull : 4, Flickering1 : 10, Flickering2 : 11, Flickering3 : 12, LeftToRight1 : 20, LeftToRight2 : 21, RightToLeft1 : 22, RightToLeft2 : 23, TwoWay : 24, |
ProgressBar.CreationType |
Replace : 0, AppendChild : 1, |
ProgressBar.Direction |
LeftToRight : 0, RightToLeft : 1, TopToBottom : 0, BottomToTop : 1, |
ProgressBar.Orientation |
Horizontal : 0, Vertical : 1, |
<div id="my_progress_bar" class="progressbar_parent"> <div class="progressbar_background"></div> <div class="progressbar_left"></div> <div class="progressbar_middle"> <div class=""></div> </div> <div class="progressbar_right"></div> <div class="progressbar_marker"></div> <div class="progressbar_text_horizontal">Loaded in 45 %</div> </div>Whereas if foreground image width is greater or equal to progress bar width, then progress bar HTML looks like that:
<div id="my_progress_bar" class="progressbar_parent"> <div class="progressbar_background"></div> <div class="progressbar_wrapper"></div> <div class="progressbar_marker"></div> <div class="progressbar_text_horizontal">Loaded in 45 %</div> </div>Knowing this could be useful when You would like to modify progress bar appearance by CSS styles or programmatically.