Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
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:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.lang.timing.Timer");
14
dojo.require("dojo.lang.func");
15
dojo.lang.timing.Timer = function (interval) {
16
	this.timer = null;
17
	this.isRunning = false;
18
	this.interval = interval;
19
	this.onStart = null;
20
	this.onStop = null;
21
};
22
dojo.extend(dojo.lang.timing.Timer, {onTick:function () {
23
}, setInterval:function (interval) {
24
	if (this.isRunning) {
25
		dj_global.clearInterval(this.timer);
26
	}
27
	this.interval = interval;
28
	if (this.isRunning) {
29
		this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval);
30
	}
31
}, start:function () {
32
	if (typeof this.onStart == "function") {
33
		this.onStart();
34
	}
35
	this.isRunning = true;
36
	this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval);
37
}, stop:function () {
38
	if (typeof this.onStop == "function") {
39
		this.onStop();
40
	}
41
	this.isRunning = false;
42
	dj_global.clearInterval(this.timer);
43
}});
44