Permalink
Browse files

Merge pull request #1 from Siedrix/master

Added node.js support
  • Loading branch information...
2 parents de0b7fb + 1e91879 commit 8b9e5ba6756861d65ca014d86aad060a978164bf @azendal committed Dec 21, 2011
Showing with 65 additions and 5 deletions.
  1. +11 −0 browser.html
  2. +9 −5 neon.js
  3. +45 −0 node.js
View
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Neon</title>
+ <script src="neon.js" type="text/javascript"></script>
+</head>
+<body>
+ <h1>Neon</h1>
+</body>
+</html>
+
View
14 neon.js
@@ -45,7 +45,9 @@
* }
* });
*/
-var Interface = function Interface(nameOrNameSpace, name){
+(function (global){
+
+global.Interface = function Interface(nameOrNameSpace, name){
var nameSpace, interfaceName, factory;
nameSpace = (nameOrNameSpace && name) ? nameOrNameSpace : this;
interfaceName = (nameOrNameSpace && name) ? name :
@@ -59,7 +61,7 @@ var Interface = function Interface(nameOrNameSpace, name){
return factory;
};
-var Module = function Module(nameOrNameSpace, name){
+global.Module = function Module(nameOrNameSpace, name){
var nameSpace, moduleName, factory;
nameSpace = (nameOrNameSpace && name) ? nameOrNameSpace : this;
moduleName = (nameOrNameSpace && name) ? name :
@@ -72,7 +74,7 @@ var Module = function Module(nameOrNameSpace, name){
return factory;
};
-var Class = function Class(classNameOrNameSpace, className){
+global.Class = function Class(classNameOrNameSpace, className){
var nameSpace, newClass, classFactory;
nameSpace = (classNameOrNameSpace && className) ? classNameOrNameSpace : this;
className = (classNameOrNameSpace && className) ? className :
@@ -133,7 +135,7 @@ var Class = function Class(classNameOrNameSpace, className){
for(i = 0, il = newClass.__implementedInterfaces.length; i < il; i++){
for(j = 0, jl = newClass.__implementedInterfaces[i].constructor.length; j < jl; j++){
if(!newClass[ newClass.__implementedInterfaces[i].constructor[j] ]){
- alert('must implement static ' + newClass.__implementedInterfaces[i].name);
+ console.log('must implement static ' + newClass.__implementedInterfaces[i].name);
break;
}
}
@@ -142,7 +144,7 @@ var Class = function Class(classNameOrNameSpace, className){
&& newClass.__implementedInterfaces[i].prototype){
for(j = 0, jl = newClass.__implementedInterfaces[i].prototype.length; j < jl; j++){
if(!newClass.prototype[newClass.__implementedInterfaces[i].prototype[j]]){
- alert('must implement prototype ' + newClass.__implementedInterfaces[i].name);
+ console.log('must implement prototype ' + newClass.__implementedInterfaces[i].name);
break;
}
}
@@ -195,3 +197,5 @@ var Class = function Class(classNameOrNameSpace, className){
return classFactory;
};
+
+}(typeof window === 'undefined' ? exports : window));
View
45 node.js
@@ -0,0 +1,45 @@
+var Neon = require('./neon.js');
+
+console.log('Neon Class :',typeof Neon.Class);
+console.log('Neon Module :',typeof Neon.Module);
+console.log('Neon Interface :',typeof Neon.Interface);
+
+var Class = Neon.Class;
+var Module = Neon.Module;
+var Interface = Neon.Interface;
+
+console.log('Neon Class :',typeof Class);
+console.log('Module :',typeof Module);
+console.log('Interface :',typeof Interface);
+
+Module('Composition')({
+ y : 5,
+ prototype : {
+ z : 3
+ }
+});
+
+Interface('Editable')({
+ constructor : ['x'],
+ prototype : ['x']
+});
+
+Class('Widget')({
+
+});
+
+Class('Overlay').inherits(Widget).ensures(Editable).includes(Composition)({
+ html : '<div></div>',
+ x : 10,
+ prototype : {
+ init : function (element){
+ if(!element){
+ element = document.createElement('div');
+ element.innerHTML = 'hola';
+ document.body.appendChild(element);
+ }
+ },
+ x : 10,
+ b : 5
+ }
+});

0 comments on commit 8b9e5ba

Please sign in to comment.