]>
git.r.bdr.sh - rbdr/r.bdr.sh/blob - jekyll/js/vendor/neon/neon.js
2 if (typeof global
=== "undefined") {
6 global
.Interface
= function Interface(nameOrNameSpace
, name
) {
7 var nameSpace
, interfaceName
, factory
;
8 nameSpace
= (nameOrNameSpace
&& name
) ? nameOrNameSpace : this;
9 interfaceName
= (nameOrNameSpace
&& name
) ? name :
10 (nameOrNameSpace
) ? nameOrNameSpace : 'interface' + Math
.random().toString();
11 factory = function(definition
) {
12 definition
.isInterface
= true;
13 definition
.name
= interfaceName
;
14 nameSpace
[interfaceName
] = definition
;
15 return nameSpace
[interfaceName
];
20 global
.Module
= function Module(nameOrNameSpace
, name
) {
21 var nameSpace
, moduleName
, factory
, newModule
;
23 nameSpace
= (nameOrNameSpace
&& name
) ? nameOrNameSpace : this;
24 moduleName
= (nameOrNameSpace
&& name
) ? name :
25 (nameOrNameSpace
) ? nameOrNameSpace : 'module' + Math
.random().toString();
28 moduleName : moduleName
,
30 __includedModules : [],
31 include : function(module
) {
33 for (property
in module
) {
34 if (module
.hasOwnProperty(property
)
35 && property
!== 'prototype'
36 && property
!== 'isModule'
37 && property
!== '__includedModules'
38 && property
!== 'include'
39 && property
!== 'moduleName') {
40 newModule
[property
] = module
[property
];
44 if (module
.hasOwnProperty('prototype') && module
.prototype) {
45 for (property
in module
.prototype) {
46 if (module
.prototype.hasOwnProperty(property
)) {
47 newModule
.prototype[property
] = module
.prototype[property
];
52 module
.prototype = {};
55 this.__includedModules
.push(module
);
61 factory = function(definition
){
64 newModule
.isModule
= true;
66 for (property
in definition
) {
67 if (definition
.hasOwnProperty(property
)
68 && property
!== 'prototype'
69 && property
!== 'isModule'
70 && property
!== '__includedModules'
71 && property
!== 'include'
72 && property
!== 'moduleName') {
73 newModule
[property
] = definition
[property
];
77 if (definition
.hasOwnProperty('prototype') && definition
.prototype) {
78 for (property
in definition
.prototype) {
79 if (definition
.prototype.hasOwnProperty(property
)) {
80 newModule
.prototype[property
] = definition
.prototype[property
];
85 nameSpace
[moduleName
] = newModule
;
87 return nameSpace
[moduleName
];
90 factory
.includes = function () {
91 for(var i
= 0; i
< arguments
.length
; i
++){
92 newModule
.include(arguments
[i
]);
100 global
.Class
= function Class(classNameOrNameSpace
, className
) {
101 var nameSpace
, newClass
, classFactory
;
102 nameSpace
= (classNameOrNameSpace
&& className
) ? classNameOrNameSpace : global
;
103 className
= (classNameOrNameSpace
&& className
) ? className :
104 (classNameOrNameSpace
) ? classNameOrNameSpace : 'class' + Math
.random().toString();
106 newClass = function() {
108 this.init
.apply(this, arguments
);
112 newClass
.__descendants
= [];
113 newClass
.__implementedInterfaces
= [];
114 newClass
.__includedModules
= [];
115 newClass
.className
= className
;
116 newClass
.include = function(module
) {
118 for (property
in module
) {
119 if (module
.hasOwnProperty(property
)
120 && property
!= 'prototype'
121 && property
!= 'constructor'
122 && property
!= 'isModule'
123 && property
!= 'superClass'
124 && property
!= 'include') {
125 newClass
[property
] = module
[property
];
129 if (module
.hasOwnProperty('prototype') && module
.prototype) {
130 for (property
in module
.prototype) {
131 if (module
.prototype.hasOwnProperty(property
)) {
132 newClass
.prototype[property
] = module
.prototype[property
];
136 module
.prototype = {};
139 newClass
.__includedModules
.push(module
);
143 classFactory = function(classDefinition
) {
144 var i
, il
, j
, jl
, property
, classPrototype
= classDefinition
.prototype;
145 if (classPrototype
) {
146 for (property
in classPrototype
) {
147 if (classPrototype
.hasOwnProperty(property
)) {
148 newClass
.prototype[property
] = classPrototype
[property
];
151 delete classDefinition
.prototype;
153 for (property
in classDefinition
) {
154 if (classDefinition
.hasOwnProperty(property
)) {
155 newClass
[property
] = classDefinition
[property
];
159 for (i
= 0, il
= newClass
.__implementedInterfaces
.length
; i
< il
; i
++) {
160 for (j
= 0, jl
= newClass
.__implementedInterfaces
[i
].constructor.length
; j
< jl
; j
++) {
161 if (!newClass
[ newClass
.__implementedInterfaces
[i
].constructor[j
] ]) {
162 console
.log('must implement static ' + newClass
.__implementedInterfaces
[i
].name
);
167 if (newClass
.__implementedInterfaces
[i
].hasOwnProperty('prototype')
168 && newClass
.__implementedInterfaces
[i
].prototype) {
169 for (j
= 0, jl
= newClass
.__implementedInterfaces
[i
].prototype.length
; j
< jl
; j
++) {
170 if (!newClass
.prototype[newClass
.__implementedInterfaces
[i
].prototype[j
]]) {
171 console
.log('must implement prototype ' + newClass
.__implementedInterfaces
[i
].name
);
179 if (Li
&& Li
.ObjectSpy
&& Li
.Spy
) {
180 newClass
.__objectSpy
= new Li
.ObjectSpy();
181 newClass
.__objectSpy
.spy(newClass
);
182 newClass
.__objectSpy
.spy(newClass
.prototype);
186 nameSpace
[className
] = newClass
;
190 classFactory
.inherits = function(superClass
) {
191 var i
, inheritedClass
;
192 newClass
.superClass
= superClass
;
193 if (superClass
.hasOwnProperty('__descendants')) {
194 superClass
.__descendants
.push(newClass
);
196 inheritedClass = function() {
198 inheritedClass
.prototype = superClass
.prototype;
199 newClass
.prototype = new inheritedClass();
200 newClass
.prototype.constructor = newClass
;
202 for (i
in superClass
) {
203 if (superClass
.hasOwnProperty(i
)
206 && i
!== 'superClass'
208 && i
!= '__descendants') {
209 newClass
[i
] = superClass
[i
];
213 delete this.inherits
;
217 classFactory
.ensures = function(interfaces
) {
218 for (var i
= 0; i
< arguments
.length
; i
++) {
219 newClass
.__implementedInterfaces
.push(arguments
[i
]);
225 classFactory
.includes = function() {
226 for (var i
= 0; i
< arguments
.length
; i
++) {
227 newClass
.include(arguments
[i
]);