Cross Reference: /yui3/src/app/tests/manual/app-transitions.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Foo App</title>
</head>
<body>
<script src="/build/yui/yui.js"></script>
<script>
YUI({
combine: false,
filter: 'RAW'
}).use('app', 'app-transitions', function (Y) {
Y.HappyView = Y.Base.create('SadView', Y.View, [], {
render: function () {
this.get('container').setContent('<p>I\'m a happy view :)</p>');
}
});
Y.SadView = Y.Base.create('SadView', Y.View, [], {
render: function () {
this.get('container').setContent('<p>I\'m a sad view :(</p>');
}
});
var MyAppClass = Y.Base.create('MyApp', Y.App, [], {
views: {
happy: {
type: Y.HappyView
},
sad: {
type: Y.SadView
}
}
}),
myAppInstance = new MyAppClass({transitions: true}).render(),
transition = function (counter) {
counter = counter || 0;
if (counter >= 21) {
return;
}
Y.later(100, null, function () {
myAppInstance.showView((counter % 2) ? 'happy' : 'sad');
transition(counter + 1);
});
};
transition();
});
</script>
</body>
</html>