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.animation.AnimationSequence");
13
dojo.provide("dojo.animation.AnimationSequence");
12
dojo.require("dojo.animation.AnimationEvent");
14
dojo.require("dojo.animation.AnimationEvent");
13
dojo.require("dojo.animation.Animation");
15
dojo.require("dojo.animation.Animation");
14
dojo.deprecated("dojo.animation.AnimationSequence is slated for removal in 0.5; use dojo.lfx.* instead.", "0.5");
16
dojo.deprecated("dojo.animation.AnimationSequence is slated for removal in 0.5; use dojo.lfx.* instead.", "0.5");
15
dojo.animation.AnimationSequence = function (repeatCount) {
17
dojo.animation.AnimationSequence = function (repeatCount) {
16
	this._anims = [];
18
	this._anims = [];
17
	this.repeatCount = repeatCount || 0;
19
	this.repeatCount = repeatCount || 0;
18
};
20
};
19
dojo.lang.extend(dojo.animation.AnimationSequence, {repeatCount:0, _anims:[], _currAnim:-1, onBegin:null, onEnd:null, onNext:null, handler:null, add:function () {
21
dojo.lang.extend(dojo.animation.AnimationSequence, {repeatCount:0, _anims:[], _currAnim:-1, onBegin:null, onEnd:null, onNext:null, handler:null, add:function () {
20
	for (var i = 0; i < arguments.length; i++) {
22
	for (var i = 0; i < arguments.length; i++) {
21
		this._anims.push(arguments[i]);
23
		this._anims.push(arguments[i]);
22
		arguments[i]._animSequence = this;
24
		arguments[i]._animSequence = this;
23
	}
25
	}
24
}, remove:function (anim) {
26
}, remove:function (anim) {
25
	for (var i = 0; i < this._anims.length; i++) {
27
	for (var i = 0; i < this._anims.length; i++) {
26
		if (this._anims[i] == anim) {
28
		if (this._anims[i] == anim) {
27
			this._anims[i]._animSequence = null;
29
			this._anims[i]._animSequence = null;
28
			this._anims.splice(i, 1);
30
			this._anims.splice(i, 1);
29
			break;
31
			break;
30
		}
32
		}
31
	}
33
	}
32
}, removeAll:function () {
34
}, removeAll:function () {
33
	for (var i = 0; i < this._anims.length; i++) {
35
	for (var i = 0; i < this._anims.length; i++) {
34
		this._anims[i]._animSequence = null;
36
		this._anims[i]._animSequence = null;
35
	}
37
	}
36
	this._anims = [];
38
	this._anims = [];
37
	this._currAnim = -1;
39
	this._currAnim = -1;
38
}, clear:function () {
40
}, clear:function () {
39
	this.removeAll();
41
	this.removeAll();
40
}, play:function (gotoStart) {
42
}, play:function (gotoStart) {
41
	if (this._anims.length == 0) {
43
	if (this._anims.length == 0) {
42
		return;
44
		return;
43
	}
45
	}
44
	if (gotoStart || !this._anims[this._currAnim]) {
46
	if (gotoStart || !this._anims[this._currAnim]) {
45
		this._currAnim = 0;
47
		this._currAnim = 0;
46
	}
48
	}
47
	if (this._anims[this._currAnim]) {
49
	if (this._anims[this._currAnim]) {
48
		if (this._currAnim == 0) {
50
		if (this._currAnim == 0) {
49
			var e = {type:"begin", animation:this._anims[this._currAnim]};
51
			var e = {type:"begin", animation:this._anims[this._currAnim]};
50
			if (typeof this.handler == "function") {
52
			if (typeof this.handler == "function") {
51
				this.handler(e);
53
				this.handler(e);
52
			}
54
			}
53
			if (typeof this.onBegin == "function") {
55
			if (typeof this.onBegin == "function") {
54
				this.onBegin(e);
56
				this.onBegin(e);
55
			}
57
			}
56
		}
58
		}
57
		this._anims[this._currAnim].play(gotoStart);
59
		this._anims[this._currAnim].play(gotoStart);
58
	}
60
	}
59
}, pause:function () {
61
}, pause:function () {
60
	if (this._anims[this._currAnim]) {
62
	if (this._anims[this._currAnim]) {
61
		this._anims[this._currAnim].pause();
63
		this._anims[this._currAnim].pause();
62
	}
64
	}
63
}, playPause:function () {
65
}, playPause:function () {
64
	if (this._anims.length == 0) {
66
	if (this._anims.length == 0) {
65
		return;
67
		return;
66
	}
68
	}
67
	if (this._currAnim == -1) {
69
	if (this._currAnim == -1) {
68
		this._currAnim = 0;
70
		this._currAnim = 0;
69
	}
71
	}
70
	if (this._anims[this._currAnim]) {
72
	if (this._anims[this._currAnim]) {
71
		this._anims[this._currAnim].playPause();
73
		this._anims[this._currAnim].playPause();
72
	}
74
	}
73
}, stop:function () {
75
}, stop:function () {
74
	if (this._anims[this._currAnim]) {
76
	if (this._anims[this._currAnim]) {
75
		this._anims[this._currAnim].stop();
77
		this._anims[this._currAnim].stop();
76
	}
78
	}
77
}, status:function () {
79
}, status:function () {
78
	if (this._anims[this._currAnim]) {
80
	if (this._anims[this._currAnim]) {
79
		return this._anims[this._currAnim].status();
81
		return this._anims[this._currAnim].status();
80
	} else {
82
	} else {
81
		return "stopped";
83
		return "stopped";
82
	}
84
	}
83
}, _setCurrent:function (anim) {
85
}, _setCurrent:function (anim) {
84
	for (var i = 0; i < this._anims.length; i++) {
86
	for (var i = 0; i < this._anims.length; i++) {
85
		if (this._anims[i] == anim) {
87
		if (this._anims[i] == anim) {
86
			this._currAnim = i;
88
			this._currAnim = i;
87
			break;
89
			break;
88
		}
90
		}
89
	}
91
	}
90
}, _playNext:function () {
92
}, _playNext:function () {
91
	if (this._currAnim == -1 || this._anims.length == 0) {
93
	if (this._currAnim == -1 || this._anims.length == 0) {
92
		return;
94
		return;
93
	}
95
	}
94
	this._currAnim++;
96
	this._currAnim++;
95
	if (this._anims[this._currAnim]) {
97
	if (this._anims[this._currAnim]) {
96
		var e = {type:"next", animation:this._anims[this._currAnim]};
98
		var e = {type:"next", animation:this._anims[this._currAnim]};
97
		if (typeof this.handler == "function") {
99
		if (typeof this.handler == "function") {
98
			this.handler(e);
100
			this.handler(e);
99
		}
101
		}
100
		if (typeof this.onNext == "function") {
102
		if (typeof this.onNext == "function") {
101
			this.onNext(e);
103
			this.onNext(e);
102
		}
104
		}
103
		this._anims[this._currAnim].play(true);
105
		this._anims[this._currAnim].play(true);
104
	} else {
106
	} else {
105
		var e = {type:"end", animation:this._anims[this._anims.length - 1]};
107
		var e = {type:"end", animation:this._anims[this._anims.length - 1]};
106
		if (typeof this.handler == "function") {
108
		if (typeof this.handler == "function") {
107
			this.handler(e);
109
			this.handler(e);
108
		}
110
		}
109
		if (typeof this.onEnd == "function") {
111
		if (typeof this.onEnd == "function") {
110
			this.onEnd(e);
112
			this.onEnd(e);
111
		}
113
		}
112
		if (this.repeatCount > 0) {
114
		if (this.repeatCount > 0) {
113
			this._currAnim = 0;
115
			this._currAnim = 0;
114
			this.repeatCount--;
116
			this.repeatCount--;
115
			this._anims[this._currAnim].play(true);
117
			this._anims[this._currAnim].play(true);
116
		} else {
118
		} else {
117
			if (this.repeatCount == -1) {
119
			if (this.repeatCount == -1) {
118
				this._currAnim = 0;
120
				this._currAnim = 0;
119
				this._anims[this._currAnim].play(true);
121
				this._anims[this._currAnim].play(true);
120
			} else {
122
			} else {
121
				this._currAnim = -1;
123
				this._currAnim = -1;
122
			}
124
			}
123
		}
125
		}
124
	}
126
	}
125
}});
127
}});
126
 
128