-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.html
More file actions
143 lines (139 loc) · 4.01 KB
/
example.html
File metadata and controls
143 lines (139 loc) · 4.01 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href='http://fonts.googleapis.com/css?family=Crete+Round' rel='stylesheet' type='text/css'>
<style>
body {
background: #333;
color: #eee;
padding: 5%;
font-family: 'Crete Round', serif;
}
h1 {
color: #C80;
text-shadow: 2px 2px 2px #000000;
}
h3 {
color: #999;
}
.half {
width: 40%;
float: left;
}
a {
color: #DFA;
}
</style>
</head>
<body>
<h1>
SeedJs
</h1>
<h3>
A library that provides you with a solid classical inheritance system in javascript. And, in the way, assimilate BackboneJs inheritance system into something more familiar for a non prototypical-minded developer.
</h3>
<section>
Some <a href="readme.html">info</a>
</section>
<h2>
Use your javascript console to play with the provided examples of classes:
</h2>
<section>
<div class="half">
<pre>
Vehicle = Seed.extend({
engine:{cilindros:0, pistones:0},
wheels:0,
doors:0,
speed: 0,
noise: "rrrrrrrr",
run: function() {
$('body').append(this.noise);
},
accelerate: function() {
this.speed += 10;
console.log('new speed:' + this.speed);
},
brake: function() {
this.speed -= 10;
}
});
</pre>
</div>
<div class="half">
<pre>
Car = Vehicle.extend({wheels: 4,
doors:4,
noise: "brrum brrrum"
});
Motorbike = Vehicle.extend({wheels: 2});
Clio = Car.extend({
engine:{cilindros:8, pistones:16},
accelerate: function() {
this.parent('accelerate');
if(this.speed > 50) {
this.speed = 0;
alert('CRASH');
}
},
run: function() {
this.accelerate();
this.parent('run');
}
});
Yamaha = Motorbike.extend({engine:{cilindros:4, pistones:10}});
</pre>
</div>
</section>
<section>
<div class="half">
Get it at <a href="https://github.com/johnHackworth/SeedJs">https://github.com/johnHackworth/SeedJs</a>
</div>
<div class="half">
Check the <a href="backbone.html">backboneJs integration example</a>
</div>
</section>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://raw.github.com/johnHackworth/SeedJs/master/bin/seed.js"></script>
<script>
window.Vehicle = Seed.extend({
engine:{cilindros:0, pistones:0},
wheels:0,
doors:0,
speed: 0,
noise: "rrrrrrrr",
run: function() {
$('body').append(this.noise);
},
accelerate: function() {
this.speed += 10;
console.log('new speed:' + this.speed);
},
brake: function() {
this.speed -= 10;
}
});
window.Car = Vehicle.extend({wheels: 4,
doors:4,
noise: "brrum brrrum"
});
window.Motorbike = Vehicle.extend({wheels: 2});
window.Clio = Car.extend({
engine:{cilindros:8, pistones:16},
accelerate: function() {
this.parent('accelerate');
if(this.speed > 50) {
this.speed = 0;
alert('CRASH');
}
},
run: function() {
this.accelerate();
this.parent('run');
}
});
window.Yamaha = Motorbike.extend({engine:{cilindros:4, pistones:10}});
</script>
</body>
</html>