JqueryUI Interactions
- JqueryUI - Sortable
- JqueryUI - Selectable
- JqueryUI - Resizable
- JqueryUI - Droppable
- JqueryUI - Draggable
JqueryUI Widgets
- JqueryUI - Tooltip
- JqueryUI - Tabs
- JqueryUI - Spinner
- JqueryUI - Slider
- JqueryUI - Progressbar
- JqueryUI - Menu
- JqueryUI - Dialog
- JqueryUI - Datepicker
- JqueryUI - Button
- JqueryUI - Autocomplete
- JqueryUI - Accordion
JqueryUI Effects
- JqueryUI - Toggle Class
- JqueryUI - Toggle
- JqueryUI - Switch Class
- JqueryUI - Show
- JqueryUI - Remove Class
- JqueryUI - Hide
- JqueryUI - Effect
- JqueryUI - Color Animation
- JqueryUI - Add Class
JqueryUI Utilities
JqueryUI Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
JqueryUI - Progressbar
Progress bars indicate the completion percentage of an operation or process. We can categorize progress bar as determinate progress bar and indeterminate progress bar.
Determinate progress bar should only be used in situations where the system can accurately update the current status. A determinate progress bar should never fill from left to right, then loop back to empty for a single process.
If the actual status cannot be calculated, an indeterminate progress bar should be used to provide user feedback.
jQueryUI provides an easy-to-use progress bar widget that we can use to let users know that our apppcation is hard at work performing the requested operation. jQueryUI provides progressbar() method to create progress bars.
Syntax
The progressbar() method can be used in two forms −
Method
Method
$ (selector, context).progressbar (options) Method
The progressbar (options) method declares that an HTML element can be managed in the form of a progress bar. The options parameter is an object that specifies the appearance and behavior of progress bars.
Syntax
$(selector, context).progressbar (options);
You can provide one or more options at a time using Javascript object. If there are more than one options to be provided then you will separate them using a comma as follows −
$(selector, context).progressbar({option1: value1, option2: value2..... });
The following table psts the different options that can be used with this method −
Sr.No. | Option & Description |
---|---|
1 | This option when set to true disables the progress bars. By default its value is false. |
2 | This option sets the maximum value for a progress bar. By default its value is 100. |
3 | This option specifies the initial value of the progress bar. By default its value is 0. |
The following section will show you a few working examples of progressbar functionapty.
Default Functionapty
The following example demonstrates a simple example of progressbar functionapty, passing no parameters to the progressbar() method.
<!doctype html> <html lang = "en"> <head> <meta charset = "utf-8"> <title>jQuery UI ProgressBar functionapty</title> <pnk href = "https://code.jquery.com/ui/1.10.4/themes/ui-pghtness/jquery-ui.css" rel = "stylesheet"> <script src = "https://code.jquery.com/jquery-1.10.2.js"></script> <script src = "https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <style> .ui-widget-header { background: #cedc98; border: 1px sopd #DDDDDD; color: #333333; font-weight: bold; } </style> <script> $(function() { $( "#progressbar-1" ).progressbar({ value: 30 }); }); </script> </head> <body> <span id = "progressbar-1"></span> </body> </html>
Let us save the above code in an HTML file progressbarexample.htm and open it in a standard browser which supports javascript, you must also see the following output. Now, you can play with the result −
This example shows the creation of progress bar using of progressbar() method. This is a default determinate progress bar.
Use of max and value
The following example demonstrates the usage of two options values and max in the progressbar function of JqueryUI.
<!doctype html> <html lang = "en"> <head> <meta charset = "utf-8"> <title>jQuery UI ProgressBar functionapty</title> <pnk href = "https://code.jquery.com/ui/1.10.4/themes/ui-pghtness/jquery-ui.css" rel = "stylesheet"> <script src = "https://code.jquery.com/jquery-1.10.2.js"></script> <script src = "https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <style> .ui-widget-header { background: #cedc98; border: 1px sopd #DDDDDD; color: #333333; font-weight: bold; } </style> <script> $(function() { var progressbar = $( "#progressbar-2" ); $( "#progressbar-2" ).progressbar({ value: 30, max:300 }); function progress() { var val = progressbar.progressbar( "value" ) || 0; progressbar.progressbar( "value", val + 1 ); if ( val < 99 ) { setTimeout( progress, 100 ); } } setTimeout( progress, 3000 ); }); </script> </head> <body> <span id = "progressbar-2"></span> </body> </html>
Let us save the above code in an HTML file progressbarexample.htm and open it in a standard browser which supports javascript, you must also see the following output. Now, you can play with the result −
Here you can see that the progress bar fills from right to left and stops when the value reaches 300.
$ (selector, context).progressbar ("action", params) Method
The progressbar ("action", params) method can perform an action on progress bar, such as changing the percentage filled. The action is specified as a string in the first argument (e.g., "value" to change the percentage filled). Check out the actions that can be passed, in the following table.
Syntax
$(selector, context).progressbar ("action", params);;
The following table psts the different actions that can be used with this method −
Sr.No. | Action & Description |
---|---|
1 | This action removes the progress bar functionapty of an element completely. The elements return to their pre-init state. This method does not accept any arguments. |
2 | This action removes the progress bar functionapty of an element completely. The elements return to their pre-init state. This method does not accept any arguments. |
3 | This action disables the progress bar functionapty of an element. This method does not accept any arguments. |
4 | This action enables the progress bar functionapty. This method does not accept any arguments. |
5 | This action retrieves the value currently associated with specified optionName. Where optionName is a String. |
6 | This action gets an object containing key/value pairs representing the current progressbar options hash. This method does not accept any arguments. |
7 | This action sets the value of the progressbar option associated with the specified optionName. |
8 | This action sets one or more options for the progress bars. The argument options is a map of option-value pairs to be set. |
9 | This action retrieves the current value of options.value, that is, the percentage of fill in the progress bar. |
10 | This action specifies a new value to the percentage filled in the progress bar. The argument value can be a Number or Boolean. |
11 | This action returns a jQuery object containing the progressbar. This method does not accept any arguments. |
Sr.No. | Event Method & Description |
---|---|
1 | This event is triggered whenever the value of progress bar changes. Where event is of type Event, and ui is of type Object. |
2 | This event is triggered when the progressbar reaches the maximumm value. Where event is of type Event, and ui is of type Object. |
3 | This event is triggered whenever progressbar is created. Where event is of type Event, and ui is of type Object. |
Example
The following example demonstrates the event method usage during progressbar functionapty. This example demonstrates the use of events change and complete.
<!doctype html> <html lang = "en"> <head> <meta charset = "utf-8"> <title>jQuery UI ProgressBar functionapty</title> <pnk href = "https://code.jquery.com/ui/1.10.4/themes/ui-pghtness/jquery-ui.css" rel = "stylesheet"> <script src = "https://code.jquery.com/jquery-1.10.2.js"></script> <script src = "https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <style> .ui-widget-header { background: #cedc98; border: 1px sopd #DDDDDD; color: #333333; font-weight: bold; } .progress-label { position: absolute; left: 50%; top: 13px; font-weight: bold; text-shadow: 1px 1px 0 #fff; } </style> <script> $(function() { var progressbar = $( "#progressbar-5" ); progressLabel = $( ".progress-label" ); $( "#progressbar-5" ).progressbar({ value: false, change: function() { progressLabel.text( progressbar.progressbar( "value" ) + "%" ); }, complete: function() { progressLabel.text( "Loading Completed!" ); } }); function progress() { var val = progressbar.progressbar( "value" ) || 0; progressbar.progressbar( "value", val + 1 ); if ( val < 99 ) { setTimeout( progress, 100 ); } } setTimeout( progress, 3000 ); }); </script> </head> <body> <span id = "progressbar-5"> <span class = "progress-label"> Loading... </span> </span> </body> </html>
Let us save the above code in an HTML file progressbarexample.htm and open it in a standard browser which supports javascript, you must also see the following output −
Here you can see as the progressbar changes its changed value is printed and upon complete event the "Loading Completed!" message displays.
Advertisements