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)
33 Console.log("Value is changed to " + val);
38 You can use the value method with the pickers to set or get the current default progress bar value:
40 <div id="foo" data-role="progressbar"></div>
41 var oldVal = $("#foo").progress("option", "value");
42 $("#foo").progress("option", "value", 50);
45 (function ( $, window, undefined ) {
47 $.widget( "tizen.progressbar", $.mobile.widget, {
55 _create: function () {
57 .addClass( "ui-progressbar" )
60 "aria-valuemin": this.min,
61 "aria-valuemax": this.options.max,
62 "aria-valuenow": this._value()
65 this.valueDiv = $( "<div class='ui-progressbar-value'></div>" )
66 .appendTo( this.element );
68 this.valueDiv.wrap("<div class='ui-progress-bg'></div>");
70 this.oldValue = this._value();
74 _destroy: function () {
76 .removeClass( "ui-progressbar" )
78 .removeAttr( "aria-valuemin" )
79 .removeAttr( "aria-valuemax" )
80 .removeAttr( "aria-valuenow" );
82 this.valueDiv.remove();
85 value: function ( newValue ) {
86 if ( newValue === undefined ) {
90 this._setOption( "value", newValue );
94 _setOption: function ( key, value ) {
95 if ( key === "value" ) {
96 this.options.value = value;
98 if ( this._value() === this.options.max ) {
99 this._trigger( "complete" );
102 // jquery.ui.widget.js MUST be updated to new version!
103 //this._super( "_setOption", key, value );
106 _value: function () {
107 var val = this.options.value;
108 // normalize invalid value
109 if ( typeof val !== "number" ) {
112 return Math.min( this.options.max, Math.max( this.min, val ) );
115 _percentage: function () {
116 return 100 * this._value() / this.options.max;
119 _refreshValue: function () {
120 var value = this.value(),
121 percentage = this._percentage();
123 if ( this.oldValue !== value ) {
124 this.oldValue = value;
125 this._trigger( "change" );
129 .toggle( value > this.min )
130 .width( percentage.toFixed(0) + "%" );
131 this.element.attr( "aria-valuenow", value );
135 // auto self-init widgets
136 $( document ).bind( "pagecreate", function ( e ) {
137 $( e.target ).find( ":jqmData(role='progressbar')" ).progressbar();