summaryrefslogtreecommitdiff
path: root/demos/tizen-winsets/widgets/progressbar.js
blob: fa6016fab8f6180a5da0eaf2bc51b283231c2e23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var progressbar_running;

$("#progressbar-demo").live("pageshow", function ( e ) {

	$("#progressbarTest").bind("vclick", function ( e ) {
		progressbar_running = !progressbar_running;

		// request animation frame
		window.requestAnimFrame = (function () {
			return window.requestAnimationFrame ||
				window.webkitRequestAnimationFrame ||
				window.mozRequestAnimationFrame ||
				window.oRequestAnimationFrame ||
				window.msRequestAnimationFrame ||
				function (animloop) {
					return window.setTimeout(animloop, 1000 / 60);
				};
		}());

		window.cancelRequestAnimFrame = (function () {
			return window.cancelAnimationFrame ||
				window.webkitCancelRequestAnimationFrame ||
				window.mozCancelRequestAnimationFrame ||
				window.oCancelRequestAnimationFrame ||
				window.msCancelRequestAnimationFrame ||
				clearTimeout;
		}());

		var request,
			i = 0;

		// start and run the animloop
		(function animloop() {
			if ( !progressbar_running ) {
				cancelRequestAnimFrame( request );
				return;
			}

			$("#progressbar").progressbar( "option", "value", i++ );

			request = requestAnimFrame( animloop );

			if ( i > 100 ) {
				cancelRequestAnimFrame( request );
			}
		}());
	});

	$("#pending").progress( "running", true );
	$("#progressing").progress( "running", true );

	$("#pendingTest").bind("vclick", function ( e ) {
		var running = $("#pending").progress( "running" );
		// start/stop progressing animation
		$("#pending").progress( "running", !running );
	});

	$("#progressingTest").bind("vclick", function ( e ) {
		var running = $("#progressing").progress( "running" );
		// start/stop progressing animation
		$("#progressing").progress( "running", !running );

		if ( running ) {
			$("#progressing").progress( "hide" );
		}
	});
});

$("#progressbar-demo").live("pagehide", function ( e ) {
	progressbar_running = false;
	$("#pending").progress( "running", false );
	$("#progressing").progress( "running", false );
});