2 * jQuery UI Progressbar @VERSION
4 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5 * Dual licensed under the MIT or GPL Version 2 licenses.
6 * http://jquery.org/license
8 * http://docs.jquery.com/UI/Progressbar
14 * jquery.ui.progressbar.js
16 /* This is from jquery ui plugin - progressbar 11/16/2011 */
21 The progress bar widget shows a control that indicates the progress percentage of an on-going operation. This widget can be scaled to fit inside a parent container.
23 To add a progress bar widget to the application, use the following code:
25 <div id="foo" data-role="progressbar"</div>
29 The progress bar can define a callback for the change event, which is fired when the progress value is changed:
30 <div id="foo" data-role="progressbar"></div>
31 $("#foo").bind("change", function (ev, val) {
32 Console.log("Value is changed to " + val);
37 You can use the value method with the pickers to set or get the current default progress bar value:
39 <div id="foo" data-role="progressbar"></div>
40 var oldVal = $("#foo").progressbar("value");
41 $("#foo").progressbar("value", 50);
44 (function ( $, window, undefined ) {
46 $.widget( "tizen.progressbar", $.mobile.widget, {
54 _create: function () {
56 .addClass( "ui-progressbar" )
59 "aria-valuemin": this.min,
60 "aria-valuemax": this.options.max,
61 "aria-valuenow": this._value()
64 this.valueDiv = $( "<div class='ui-progressbar-value'></div>" )
65 .appendTo( this.element );
67 this.valueDiv.wrap("<div class='ui-progressbar-bg'></div>");
69 this.oldValue = this._value();
73 _destroy: function () {
75 .removeClass( "ui-progressbar" )
77 .removeAttr( "aria-valuemin" )
78 .removeAttr( "aria-valuemax" )
79 .removeAttr( "aria-valuenow" );
81 this.valueDiv.remove();
84 value: function ( newValue ) {
85 if ( newValue === undefined ) {
89 this._setOption( "value", newValue );
93 _setOption: function ( key, value ) {
94 if ( key === "value" ) {
95 this.options.value = value;
97 if ( this._value() === this.options.max ) {
98 this._trigger( "complete" );
101 // jquery.ui.widget.js MUST be updated to new version!
102 //this._super( "_setOption", key, value );
105 _value: function () {
106 var val = this.options.value;
107 // normalize invalid value
108 if ( typeof val !== "number" ) {
111 return Math.min( this.options.max, Math.max( this.min, val ) );
114 _percentage: function () {
115 return 100 * this._value() / this.options.max;
118 _refreshValue: function () {
119 var value = this.value(),
120 percentage = this._percentage();
122 if ( this.oldValue !== value ) {
123 this.oldValue = value;
124 this._trigger( "change" );
128 .toggle( value > this.min )
129 .width( percentage.toFixed(0) + "%" );
130 this.element.attr( "aria-valuenow", value );
134 // auto self-init widgets
135 $( document ).bind( "pagecreate", function ( e ) {
136 $( e.target ).find( ":jqmData(role='progressbar')" ).progressbar();