3 * jQuery UI Progressbar @VERSION
5 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
6 * Dual licensed under the MIT or GPL Version 2 licenses.
7 * http://jquery.org/license
9 * http://docs.jquery.com/UI/Progressbar
15 * jquery.ui.progressbar.js
17 /* This is from jquery ui plugin - progressbar 11/16/2011 */
19 (function( $, window, undefined ) {
21 $.widget( "tizen.progressbar", $.mobile.widget, {
31 .addClass( "ui-progressbar" )
34 "aria-valuemin": this.min,
35 "aria-valuemax": this.options.max,
36 "aria-valuenow": this._value()
39 this.valueDiv = $( "<div class='ui-progressbar-value'></div>" )
40 .appendTo( this.element );
42 this.oldValue = this._value();
46 _destroy: function() {
48 .removeClass( "ui-progressbar" )
50 .removeAttr( "aria-valuemin" )
51 .removeAttr( "aria-valuemax" )
52 .removeAttr( "aria-valuenow" );
54 this.valueDiv.remove();
57 value: function( newValue ) {
58 if ( newValue === undefined ) {
62 this._setOption( "value", newValue );
66 _setOption: function( key, value ) {
67 if ( key === "value" ) {
68 this.options.value = value;
70 if ( this._value() === this.options.max ) {
71 this._trigger( "complete" );
74 // jquery.ui.widget.js MUST be updated to new version!
75 //this._super( "_setOption", key, value );
79 var val = this.options.value;
80 // normalize invalid value
81 if ( typeof val !== "number" ) {
84 return Math.min( this.options.max, Math.max( this.min, val ) );
87 _percentage: function() {
88 return 100 * this._value() / this.options.max;
91 _refreshValue: function() {
92 var value = this.value();
93 var percentage = this._percentage();
95 if ( this.oldValue !== value ) {
96 this.oldValue = value;
97 this._trigger( "change" );
101 .toggle( value > this.min )
102 .width( percentage.toFixed(0) + "%" );
103 this.element.attr( "aria-valuenow", value );
107 // auto self-init widgets
108 $(document).bind("pagecreate", function (e) {
109 $(e.target).find(":jqmData(role='progressbar')").progressbar();