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 */
18 (function ( $, window, undefined ) {
20 $.widget( "tizen.progressbar", $.mobile.widget, {
28 _create: function () {
30 .addClass( "ui-progressbar" )
33 "aria-valuemin": this.min,
34 "aria-valuemax": this.options.max,
35 "aria-valuenow": this._value()
38 this.valueDiv = $( "<div class='ui-progressbar-value'></div>" )
39 .appendTo( this.element );
41 this.valueDiv.wrap("<div class='ui-progress-bg'></div>");
43 this.oldValue = this._value();
47 _destroy: function () {
49 .removeClass( "ui-progressbar" )
51 .removeAttr( "aria-valuemin" )
52 .removeAttr( "aria-valuemax" )
53 .removeAttr( "aria-valuenow" );
55 this.valueDiv.remove();
58 value: function ( newValue ) {
59 if ( newValue === undefined ) {
63 this._setOption( "value", newValue );
67 _setOption: function ( key, value ) {
68 if ( key === "value" ) {
69 this.options.value = value;
71 if ( this._value() === this.options.max ) {
72 this._trigger( "complete" );
75 // jquery.ui.widget.js MUST be updated to new version!
76 //this._super( "_setOption", key, value );
80 var val = this.options.value;
81 // normalize invalid value
82 if ( typeof val !== "number" ) {
85 return Math.min( this.options.max, Math.max( this.min, val ) );
88 _percentage: function () {
89 return 100 * this._value() / this.options.max;
92 _refreshValue: function () {
93 var value = this.value(),
94 percentage = this._percentage();
96 if ( this.oldValue !== value ) {
97 this.oldValue = value;
98 this._trigger( "change" );
102 .toggle( value > this.min )
103 .width( percentage.toFixed(0) + "%" );
104 this.element.attr( "aria-valuenow", value );
108 // auto self-init widgets
109 $( document ).bind( "pagecreate", function ( e ) {
110 $( e.target ).find( ":jqmData(role='progressbar')" ).progressbar();