1 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2 //>>description: Shows progressbar or progress circle
4 //>>group: Tizen:Widgets
6 define( [ '../jquery.mobile.tizen.core' ], function ( ) {
7 //>>excludeEnd("jqmBuildExclude");
9 /* ***************************************************************************
10 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software" ),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included in
20 * all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
29 * ***************************************************************************
31 * Author: Minkyu Kang <mk7.kang@samsung.com>
32 * Author: Koeun Choi <koeun.choi@samsung.com>
40 * data-role: set to 'progress'.
41 * data-style: 'circle' or 'pending'.
45 * show(): show the progress.
46 * hide(): hide the progress.
47 * running(boolean): start or stop the running.
55 * <li data-role="list-divider">Progress Pending</li>
57 * <div data-role="progress" data-style="pending" id="pending"></div>
59 * <li data-role="list-divider">Progress ~ing</li>
61 * <div data-role="progress" data-style="circle" id="progress"></div>Loading..
64 * $("#pending").progress( "running", true );
65 * $("#progress").progress( "running", true );
71 The progress widget shows that an operation is in progress. <br/>To add a progress widget to the application, use the following code:
73 <div data-role="progress" data-style="circle"></div>
76 @property {String} data-style
77 Sets the style of the progress widget. The style options are pending (pending progress style) and circle (circular progress status style).
81 The running method is used to set the current running state of the pending or circular progress widget:
83 <div id="foo" data-role="progress" data-style="pending"></div>
84 $("#foo").progress("running", true);
88 The show method is used to show the pending or circular progress widget:
90 <div id="foo" data-role="progress" data-style="pending"></div>
91 $("#foo").progress("show");
95 The show method is used to hide the pending or circular progress widget:
97 <div id="foo" data-role="progress" data-style="pending"></div>
98 $("#foo").progress("hide");
101 (function ( $, window, undefined ) {
102 $.widget( "tizen.progress", $.mobile.widget, {
109 $( this.element ).show();
113 $( this.element ).hide();
116 _start: function () {
118 $( this.element ).append( this.html );
125 .find( ".ui-progress-" + this.options.style )
126 .addClass( this.runningClass );
131 .find( ".ui-progress-" + this.options.style )
132 .removeClass( this.runningClass );
135 running: function ( running ) {
136 if ( running === undefined ) {
137 return this.options.running;
140 this._setOption( "running", running );
143 _setOption: function ( key, value ) {
144 if ( key === "running" ) {
145 if ( typeof value !== "boolean" ) {
146 window.alert( "running value MUST be boolean type!" );
150 this.options.running = value;
155 _refresh: function () {
156 if ( this.options.running ) {
163 _create: function () {
165 element = this.element,
166 style = element.jqmData( "style" ),
171 this.options.style = style;
173 style = this.options.style;
176 if ( style == "circle" ) {
177 $( this.element ).addClass("ui-progress-container-circle");
179 _html = '<div class="ui-progress-circle"></div>';
180 } else if ( style === "pending" ) {
181 $( this.element ).addClass("ui-progressbar");
183 _html = '<div class="ui-progressbar-bg">' +
184 '<div class="ui-progress-pending"></div>' +
188 this.html = $( _html );
190 runningClass = "ui-progress-" + style + "-running";
194 runningClass: runningClass
197 if ( style === "pending" ) {
198 $( this.element ).append( this.html );
204 } ); /* End of widget */
206 $( document ).bind( "pagecreate create", function ( e ) {
207 $( e.target ).find( ":jqmData(role='progress')" ).progress();
211 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
213 //>>excludeEnd("jqmBuildExclude");