Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1318 Rev 1422
1
/*
1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
3
	All Rights Reserved.
4
 
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
9
*/
-
 
10
 
-
 
11
 
10
 
12
 
11
dojo.provide("dojo.lang.timing.Timer");
13
dojo.provide("dojo.lang.timing.Timer");
12
dojo.require("dojo.lang.func");
14
dojo.require("dojo.lang.func");
13
dojo.lang.timing.Timer = function (interval) {
15
dojo.lang.timing.Timer = function (interval) {
14
	this.timer = null;
16
	this.timer = null;
15
	this.isRunning = false;
17
	this.isRunning = false;
16
	this.interval = interval;
18
	this.interval = interval;
17
	this.onStart = null;
19
	this.onStart = null;
18
	this.onStop = null;
20
	this.onStop = null;
19
};
21
};
20
dojo.extend(dojo.lang.timing.Timer, {onTick:function () {
22
dojo.extend(dojo.lang.timing.Timer, {onTick:function () {
21
}, setInterval:function (interval) {
23
}, setInterval:function (interval) {
22
	if (this.isRunning) {
24
	if (this.isRunning) {
23
		dj_global.clearInterval(this.timer);
25
		dj_global.clearInterval(this.timer);
24
	}
26
	}
25
	this.interval = interval;
27
	this.interval = interval;
26
	if (this.isRunning) {
28
	if (this.isRunning) {
27
		this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval);
29
		this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval);
28
	}
30
	}
29
}, start:function () {
31
}, start:function () {
30
	if (typeof this.onStart == "function") {
32
	if (typeof this.onStart == "function") {
31
		this.onStart();
33
		this.onStart();
32
	}
34
	}
33
	this.isRunning = true;
35
	this.isRunning = true;
34
	this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval);
36
	this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval);
35
}, stop:function () {
37
}, stop:function () {
36
	if (typeof this.onStop == "function") {
38
	if (typeof this.onStop == "function") {
37
		this.onStop();
39
		this.onStop();
38
	}
40
	}
39
	this.isRunning = false;
41
	this.isRunning = false;
40
	dj_global.clearInterval(this.timer);
42
	dj_global.clearInterval(this.timer);
41
}});
43
}});
42
 
44