-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
153 lines (96 loc) · 3.61 KB
/
index.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
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
144
145
146
147
148
149
150
151
152
153
<!doctype html public "Classical.js">
<html>
<head>
<meta charset="utf-8"/>
<title>ClassicalJS</title>
</head>
<body>
<h1>This page is currently used for tests</h1>
<h2>Feel free to open up your console and test Classical.js :)</h2>
<script type="text/javascript" src="dist/classical.js"></script>
<script>
Class.addComponent('Public', {
data: {
Public: function(name, fn) {
this.name = name;
this.fn = fn;
}
},
createComponent: function ($class, name, fn) {
if (Class.ot.isFn(name)) {
fn = name;
name = fn.name;
}
return new this.data.Public(name, fn);
},
on: {
defined: function ($class) {
var Public = this.data.Public;
Class.ot.forEach($class.components, function (component) {
if (component instanceof Public) {
$class.classConstructor.prototype[component.name] = component.fn;
}
}, this);
}
}
});
Class.addComponent('Constructor', {
data: {
Constructor: function(fn) {
this.fn = fn;
}
},
createComponent: function ($class, fn) {
return new this.data.Constructor(fn);
},
on: {
newInstance: function ($class, instance) {
var Constructor = this.data.Constructor;
var args = Class.ot.toArray(arguments).slice(2);
Class.ot.forEach($class.components, function (component) {
if (component instanceof Constructor) {
component.fn.apply(instance, args);
}
});
}
}
});
Class.addClassAnnotation('Inject', {
globalize: true,
annotation: function Inject(component, $class) {
this.tokens = Class.ot.toArray(arguments).slice(2);
}
});
Class.addAnnotation('AttrExprBinding', {
annotation: function AttrExprBInding($class, attrName) {
this.attrName = attrName;
}
})
Class.addDecorator('log', {
after: true,
decorate: function (component, $class, arg0, arg1) {
console.log('component', component);
}
});
var Gulp = Class.child();
Gulp.addDecorator('coffee');
Gulp.child('name');
+Import('...')
+Inject('Element')
var A = Class("A", function (deps) {
// Can be implicit
Constructor(function (el) {
this.el = el;
});
+AttrExprBinding('ngSrc')
Public(function srcChange(value) {
this.src = value;
});
});
thatClass.annotations = [
new Inject,
]
console.log(new A(document.body));
</script>
</body>
</html>