neon 1.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,84 @@
1
+ // @TODO: Make proper spec'ing and testing for these modules
2
+ if(typeof require !== 'undefined') {
3
+ console.log("Requiring neon stdlib from file");
4
+ require('neon');
5
+ require('neon/stdlib');
6
+ }
7
+
8
+ console.log("NeCustomEvent ", typeof NeCustomEvent !== 'undefined');
9
+ console.log("NeCustomEventSupport ", typeof NeCustomEventSupport !== 'undefined');
10
+ console.log("NodeSupport ", typeof NodeSupport !== 'undefined');
11
+ console.log("BubblingSupport ", typeof BubblingSupport !== 'undefined');
12
+
13
+ console.log("--- node support")
14
+
15
+ Class('TreeNode').includes(NodeSupport)({
16
+ prototype : {
17
+ init : function(name) {
18
+ this.name = name;
19
+ }
20
+ }
21
+ });
22
+
23
+ var root = new TreeNode('root');
24
+
25
+ console.log(root);
26
+
27
+ var left = new TreeNode('left');
28
+ var right = new TreeNode('right');
29
+
30
+ root.appendChild(left);
31
+ right.setParent(root);
32
+
33
+ console.log(root.children.indexOf(left));
34
+ console.log(left == right.parent.left);
35
+
36
+ Class('X').includes(NeCustomEventSupport)({
37
+ prototype : {
38
+ init : function() {
39
+
40
+ }
41
+ }
42
+ });
43
+
44
+ console.log('--- custom event support');
45
+
46
+ var sender = new X();
47
+
48
+ sender.dispatch('alert', { message : 'ERROR: nobody should be receiving yet' });
49
+ sender.bind('alert', function(event) {
50
+ console.log(event.message == 'TEST');
51
+ });
52
+
53
+ sender.dispatch('alert', { message : 'TEST' });
54
+
55
+ console.log('--- bubbling support');
56
+
57
+ Class('BubblingTreeNode').includes(NodeSupport, NeCustomEventSupport, BubblingSupport)({
58
+ prototype : {
59
+ init : function(name) {
60
+ this.name = name;
61
+ this.bind('alert', function(event) {
62
+ console.log("Bound to alert on init (" + this.name + ")");
63
+ });
64
+ }
65
+ }
66
+ });
67
+
68
+ var root = new BubblingTreeNode('root');
69
+ var son = root.appendChild(new BubblingTreeNode('son'));
70
+ var grandson = son.appendChild(new BubblingTreeNode('grandson'));
71
+
72
+ console.log("Bubbles up");
73
+ grandson.dispatch('alert');
74
+
75
+ console.log("Doesn't bubble down");
76
+ root.dispatch('alert');
77
+
78
+ // @ TODO : Leave this tests to azendal, I have to read the browser's propagation spec
79
+ // console.log("Prevent default");
80
+ // son.bind('alert', function(event) {
81
+ // console.log(event);
82
+ // event.preventImmediatePropagation();
83
+ // });
84
+ // grandson.dispatch('alert');
package/test/neon_test.js CHANGED
@@ -1,15 +1,9 @@
1
1
  if(typeof require !== 'undefined') { // We are in Node, need to require the file
2
2
 
3
3
  console.log("Requiring neon from file");
4
- var Neon = require('../neon.js');
5
- console.log(Neon);
6
-
4
+ require('neon');
7
5
  // In Coffeescript, the following construct is recommended
8
6
  // { Class, Module, Interface } = require('neon')
9
-
10
- var Class = Neon.Class;
11
- var Module = Neon.Module;
12
- var Interface = Neon.Interface;
13
7
  }
14
8
 
15
9
 
File without changes