-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
executable file
·97 lines (79 loc) · 2.31 KB
/
example.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!Doctype html>
<html>
<head>
<title>inherit.js example</title>
<script type="text/javascript" src="inherit.js"></script>
<script type="text/javascript">
var Animal = inherit.Base.inherit({
ctor: function () {
console.log("-> Animal.ctor called");
},
toString: function () {
console.log("I'm an animal");
},
foo: function () {
console.log("Animal.foo called");
}
});
var Cat = Animal.inherit({
ctor: function (name) {
console.log("Cat.ctor called");
// call base constructor
this.base.ctor.callBase(this);
this.name = name;
},
toString: function () {
// overwrite toString method from Animal
console.log("I'm a cat. My name is " + this.name + ".");
}
});
var Lion = Cat.inherit({
ctor: function (name) {
console.log("Tiger.ctor called");
this.base.ctor.callBase(this, name);
// also call a method defined in Animal, but not redefined in Cat
this.base.foo.callBase(this);
}
})
</script>
</head>
<body>
<script type="text/javascript">
// var mizi = new Cat("Mizi");
// var leo = new Lion("Leo");
//
// mizi.toString();
// leo.toString();
var A = inherit.Base.inherit({
ctor: function () {
// A.ctor
},
className: "A"
});
var B = A.inherit({
ctor: function () {
// B.ctor
this.base.ctor.callBase(this);
this.initAttributes();
},
initAttributes: function () {
// this.base.initAttributes.callBase(this);
console.log("INIT ATTRIBUTES OF ELEMENT");
},
className: "B"
});
var C = B.inherit({
ctor: function () {
// C.ctor
this.base.ctor.callBase(this);
},
initAttributes: function () {
this.base.initAttributes.callBase(this);
console.log("INIT ATTRIBUTES OF COMPONENT");
},
className: "C"
});
var el = new C();
</script>
</body>
</html>