ninjs 0.14.1 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. data/.bundle/config +2 -2
  2. data/.travis.yml +1 -0
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +13 -11
  5. data/README.md +108 -93
  6. data/Rakefile +17 -7
  7. data/VERSION +1 -1
  8. data/bin/ninjs +24 -22
  9. data/lib/ninjs/command.rb +32 -21
  10. data/lib/ninjs/configuration.rb +35 -53
  11. data/lib/ninjs/generator.rb +6 -6
  12. data/lib/ninjs/notification.rb +5 -5
  13. data/lib/ninjs/project.rb +31 -25
  14. data/ninjs.gemspec +18 -142
  15. data/repository/ninjs/core/application.js +13 -24
  16. data/repository/ninjs/core/dom.js +87 -68
  17. data/repository/ninjs/core/existence.js +44 -105
  18. data/repository/ninjs/core/extend.js +11 -32
  19. data/repository/ninjs/core/module.js +53 -107
  20. data/repository/ninjs/core/nin.js +5 -7
  21. data/repository/ninjs/tests/extension.test.js +0 -10
  22. data/repository/ninjs/tests/index.html +19 -20
  23. data/repository/ninjs/tests/module.test.js +52 -56
  24. data/repository/ninjs/utilities/array.js +8 -8
  25. data/repository/ninjs/utilities/cookie.js +59 -0
  26. data/repository/ninjs/utilities/css.js +7 -7
  27. data/repository/ninjs/utilities/number.js +2 -2
  28. data/repository/ninjs/utilities/string.js +26 -26
  29. data/spec/cli_spec.rb +90 -88
  30. data/spec/command_spec.rb +104 -137
  31. data/spec/configuration_spec.rb +23 -37
  32. data/spec/fixtures/_global.module.js +9 -0
  33. data/spec/fixtures/compressed.myapp.js +23 -44
  34. data/spec/fixtures/foo.elements.js +1 -1
  35. data/spec/fixtures/foo.js +5 -5
  36. data/spec/fixtures/foo.model.js +1 -1
  37. data/spec/fixtures/foo.module.js +3 -3
  38. data/spec/fixtures/hello.elements.js +1 -1
  39. data/spec/fixtures/hello.js +5 -5
  40. data/spec/fixtures/hello.model.js +1 -1
  41. data/spec/fixtures/hello.module.js +3 -3
  42. data/spec/fixtures/myapp.initial.js +198 -329
  43. data/spec/fixtures/myapp.js +285 -357
  44. data/spec/fixtures/mymodule.alias.module.js +2 -2
  45. data/spec/fixtures/mymodule.dependencies.module.js +2 -2
  46. data/spec/fixtures/mymodule.elements.js +1 -1
  47. data/spec/fixtures/mymodule.model.js +1 -1
  48. data/spec/fixtures/mymodule.module.js +2 -2
  49. data/spec/fixtures/mymodule.module_alias.module.js +10 -0
  50. data/spec/fixtures/new.ninjs.conf +2 -0
  51. data/spec/fixtures/nin.js +198 -329
  52. data/spec/fixtures/ninjs.conf +2 -0
  53. data/spec/fixtures/updated.ninjs.conf +8 -0
  54. data/spec/generator_spec.rb +37 -26
  55. data/spec/ninjs_spec.rb +6 -6
  56. data/spec/project_spec.rb +229 -221
  57. data/spec/spec_helper.rb +3 -1
  58. data/spec/testspec_spec.rb +7 -0
  59. metadata +28 -145
  60. data/repository/json2.js +0 -482
  61. data/repository/modernizr/1.5.js +0 -28
  62. data/repository/modernizr/latest.js +0 -1
  63. data/repository/ninjs/docs/Data/ClassHierarchy.nd +0 -0
  64. data/repository/ninjs/docs/Data/ConfigFileInfo.nd +0 -0
  65. data/repository/ninjs/docs/Data/FileInfo.nd +0 -16
  66. data/repository/ninjs/docs/Data/ImageFileInfo.nd +0 -0
  67. data/repository/ninjs/docs/Data/ImageReferenceTable.nd +0 -0
  68. data/repository/ninjs/docs/Data/IndexInfo.nd +0 -0
  69. data/repository/ninjs/docs/Data/PreviousMenuState.nd +0 -0
  70. data/repository/ninjs/docs/Data/PreviousSettings.nd +0 -0
  71. data/repository/ninjs/docs/Data/SymbolTable.nd +0 -0
  72. data/repository/ninjs/docs/Languages.txt +0 -113
  73. data/repository/ninjs/docs/Menu.txt +0 -63
  74. data/repository/ninjs/docs/Topics.txt +0 -81
  75. data/repository/ninjs/docs/files/core/application-js.html +0 -44
  76. data/repository/ninjs/docs/files/core/existence-js.html +0 -60
  77. data/repository/ninjs/docs/files/core/extend-js.html +0 -55
  78. data/repository/ninjs/docs/files/core/module-js.html +0 -80
  79. data/repository/ninjs/docs/files/core/nin-js.html +0 -38
  80. data/repository/ninjs/docs/index.html +0 -1
  81. data/repository/ninjs/docs/index/Classes.html +0 -33
  82. data/repository/ninjs/docs/index/Files.html +0 -45
  83. data/repository/ninjs/docs/index/Functions.html +0 -65
  84. data/repository/ninjs/docs/index/General.html +0 -85
  85. data/repository/ninjs/docs/index/Variables.html +0 -45
  86. data/repository/ninjs/docs/javascript/main.js +0 -841
  87. data/repository/ninjs/docs/javascript/prettify.js +0 -1526
  88. data/repository/ninjs/docs/javascript/searchdata.js +0 -152
  89. data/repository/ninjs/docs/search/ClassesN.html +0 -20
  90. data/repository/ninjs/docs/search/FilesA.html +0 -20
  91. data/repository/ninjs/docs/search/FilesE.html +0 -20
  92. data/repository/ninjs/docs/search/FilesM.html +0 -20
  93. data/repository/ninjs/docs/search/FilesN.html +0 -20
  94. data/repository/ninjs/docs/search/FunctionsA.html +0 -20
  95. data/repository/ninjs/docs/search/FunctionsC.html +0 -20
  96. data/repository/ninjs/docs/search/FunctionsE.html +0 -20
  97. data/repository/ninjs/docs/search/FunctionsI.html +0 -20
  98. data/repository/ninjs/docs/search/FunctionsM.html +0 -20
  99. data/repository/ninjs/docs/search/FunctionsR.html +0 -20
  100. data/repository/ninjs/docs/search/FunctionsS.html +0 -20
  101. data/repository/ninjs/docs/search/FunctionsSymbols.html +0 -20
  102. data/repository/ninjs/docs/search/FunctionsU.html +0 -20
  103. data/repository/ninjs/docs/search/GeneralA.html +0 -20
  104. data/repository/ninjs/docs/search/GeneralC.html +0 -20
  105. data/repository/ninjs/docs/search/GeneralD.html +0 -20
  106. data/repository/ninjs/docs/search/GeneralE.html +0 -20
  107. data/repository/ninjs/docs/search/GeneralF.html +0 -20
  108. data/repository/ninjs/docs/search/GeneralI.html +0 -20
  109. data/repository/ninjs/docs/search/GeneralM.html +0 -20
  110. data/repository/ninjs/docs/search/GeneralN.html +0 -20
  111. data/repository/ninjs/docs/search/GeneralR.html +0 -20
  112. data/repository/ninjs/docs/search/GeneralS.html +0 -20
  113. data/repository/ninjs/docs/search/GeneralSymbols.html +0 -20
  114. data/repository/ninjs/docs/search/GeneralT.html +0 -20
  115. data/repository/ninjs/docs/search/GeneralU.html +0 -20
  116. data/repository/ninjs/docs/search/GeneralV.html +0 -20
  117. data/repository/ninjs/docs/search/NoResults.html +0 -15
  118. data/repository/ninjs/docs/search/VariablesD.html +0 -20
  119. data/repository/ninjs/docs/search/VariablesN.html +0 -20
  120. data/repository/ninjs/docs/search/VariablesR.html +0 -20
  121. data/repository/ninjs/docs/search/VariablesT.html +0 -20
  122. data/repository/ninjs/docs/styles/main.css +0 -828
  123. data/repository/nullconsole.js +0 -7
  124. data/repository/qunit/assets/css/qunit.css +0 -196
  125. data/repository/qunit/qunit.js +0 -1374
  126. data/repository/selectivizr/1.0.js +0 -5
  127. data/repository/selectivizr/latest.js +0 -1
  128. data/repository/syntaxhighlighter/all.js +0 -11
  129. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCore.css +0 -226
  130. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDefault.css +0 -328
  131. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDjango.css +0 -331
  132. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEclipse.css +0 -339
  133. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEmacs.css +0 -324
  134. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
  135. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMDUltra.css +0 -324
  136. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMidnight.css +0 -324
  137. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreRDark.css +0 -324
  138. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDefault.css +0 -117
  139. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDjango.css +0 -120
  140. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEclipse.css +0 -128
  141. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEmacs.css +0 -113
  142. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
  143. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMDUltra.css +0 -113
  144. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMidnight.css +0 -113
  145. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeRDark.css +0 -113
  146. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCore.scss +0 -216
  147. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDefault.scss +0 -2
  148. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDjango.scss +0 -2
  149. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEclipse.scss +0 -2
  150. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEmacs.scss +0 -2
  151. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreFadeToGrey.scss +0 -2
  152. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMDUltra.scss +0 -2
  153. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMidnight.scss +0 -2
  154. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreRDark.scss +0 -2
  155. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDefault.scss +0 -7
  156. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDjango.scss +0 -36
  157. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEclipse.scss +0 -48
  158. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEmacs.scss +0 -32
  159. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeFadeToGrey.scss +0 -36
  160. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMDUltra.scss +0 -32
  161. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMidnight.scss +0 -32
  162. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeRDark.scss +0 -32
  163. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_theme_template.scss +0 -120
  164. data/repository/syntaxhighlighter/shAutoloader.js +0 -17
  165. data/repository/syntaxhighlighter/shBrushAS3.js +0 -59
  166. data/repository/syntaxhighlighter/shBrushAppleScript.js +0 -75
  167. data/repository/syntaxhighlighter/shBrushBash.js +0 -59
  168. data/repository/syntaxhighlighter/shBrushCSharp.js +0 -65
  169. data/repository/syntaxhighlighter/shBrushColdFusion.js +0 -100
  170. data/repository/syntaxhighlighter/shBrushCpp.js +0 -97
  171. data/repository/syntaxhighlighter/shBrushCss.js +0 -91
  172. data/repository/syntaxhighlighter/shBrushDelphi.js +0 -55
  173. data/repository/syntaxhighlighter/shBrushDiff.js +0 -41
  174. data/repository/syntaxhighlighter/shBrushErlang.js +0 -52
  175. data/repository/syntaxhighlighter/shBrushGroovy.js +0 -67
  176. data/repository/syntaxhighlighter/shBrushJScript.js +0 -52
  177. data/repository/syntaxhighlighter/shBrushJava.js +0 -57
  178. data/repository/syntaxhighlighter/shBrushJavaFX.js +0 -58
  179. data/repository/syntaxhighlighter/shBrushPerl.js +0 -72
  180. data/repository/syntaxhighlighter/shBrushPhp.js +0 -88
  181. data/repository/syntaxhighlighter/shBrushPlain.js +0 -33
  182. data/repository/syntaxhighlighter/shBrushPowerShell.js +0 -74
  183. data/repository/syntaxhighlighter/shBrushPython.js +0 -64
  184. data/repository/syntaxhighlighter/shBrushRuby.js +0 -55
  185. data/repository/syntaxhighlighter/shBrushSass.js +0 -94
  186. data/repository/syntaxhighlighter/shBrushScala.js +0 -51
  187. data/repository/syntaxhighlighter/shBrushSql.js +0 -66
  188. data/repository/syntaxhighlighter/shBrushVb.js +0 -56
  189. data/repository/syntaxhighlighter/shBrushXml.js +0 -69
  190. data/repository/syntaxhighlighter/shCore.js +0 -17
  191. data/repository/syntaxhighlighter/shLegacy.js +0 -17
@@ -1,10 +1,10 @@
1
1
  (function(app) {
2
2
  var mod = app.add_module('mymodule');
3
3
 
4
- app.mymodule.actions = function() {
4
+ mod.actions = function() {
5
5
 
6
6
  };
7
7
 
8
- app.mymodule.run();
8
+ mod.run();
9
9
 
10
10
  })(myapp);
@@ -4,10 +4,10 @@
4
4
  //= require "../elements/mymodule.elements"
5
5
  //= require "../models/mymodule.model"
6
6
 
7
- myapp.mymodule.actions = function() {
7
+ mod.actions = function() {
8
8
 
9
9
  };
10
10
 
11
- myapp.mymodule.run();
11
+ mod.run();
12
12
 
13
13
  })();
@@ -1,5 +1,5 @@
1
1
  mod.dom.ready(function() {
2
- myapp.mymodule.elements({
2
+ mod.elements({
3
3
 
4
4
  });
5
5
  });
@@ -1,3 +1,3 @@
1
- myapp.mymodule.set_data({
1
+ mod.set_data({
2
2
 
3
3
  });
@@ -1,10 +1,10 @@
1
1
  (function() {
2
2
  var mod = myapp.add_module('mymodule');
3
3
 
4
- myapp.mymodule.actions = function() {
4
+ mod.actions = function() {
5
5
 
6
6
  };
7
7
 
8
- myapp.mymodule.run();
8
+ mod.run();
9
9
 
10
10
  })();
@@ -0,0 +1,10 @@
1
+ (function() {
2
+ var m = myapp.add_module('mymodule');
3
+
4
+ m.actions = function() {
5
+
6
+ };
7
+
8
+ m.run();
9
+
10
+ })();
@@ -1,6 +1,8 @@
1
1
  name: application
2
2
  src_dir: modules
3
3
  dest_dir: application
4
+ asset_root: ../ # relative to project root
4
5
  output: expanded
5
6
  dependencies: ['<jquery/latest>']
6
7
  autoload: ['../lib/utilities']
8
+ module_alias: mod
data/spec/fixtures/nin.js CHANGED
@@ -1,170 +1,88 @@
1
- (function() {
2
- if (window.is_defined === undefined) {
3
- window.is_defined = function(suspect) {
4
- return ((suspect === undefined) || (suspect === null)) ? false : true;
5
- };
6
- }
7
-
8
- if (!is_defined(window.is_undefined)) {
9
- window.is_undefined = function(suspect) {
10
- return (suspect === undefined) ? true : false;
11
- };
12
- }
13
-
14
- if (is_undefined(window.is_typeof)) {
15
- window.is_typeof = function(type, suspect) {
16
- if (is_undefined(type)) {
17
- throw new SyntaxError("is_typeof(Type, suspect): type is undefined");
18
- }
19
- if (is_undefined(suspect)) {
20
- throw new SyntaxError("is_typeof(Type, suspect): suspect is undefined");
21
- }
22
-
23
- return (suspect.constructor == type) ? true : false;
24
- };
25
- }
1
+ is_defined = function(suspect) {
2
+ return ((suspect === undefined) || (suspect === null)) ? false : true;
3
+ };
26
4
 
27
- if (is_undefined(window.is_numeric)) {
28
- window.is_numeric = function(suspect) {
29
- if(is_typeof(Number, suspect)) {
30
- return true;
31
- }
32
- else {
33
- var pattern = /^-?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;
34
- return pattern.test(suspect);
35
- }
36
- };
37
- }
38
-
39
- if (is_undefined(window.is_string)) {
40
- window.is_string = function(suspect) {
41
- return is_typeof(String, suspect);
42
- };
43
- }
44
-
45
- if (is_undefined(window.is_array)) {
46
- window.is_array = function(suspect) {
47
- return is_typeof(Array, suspect);
48
- };
49
- }
5
+ is_undefined = function(suspect) {
6
+ return (suspect === undefined) ? true : false;
7
+ };
50
8
 
51
- if (is_undefined(window.is_number)) {
52
- window.is_number = function(suspect) {
53
- return is_typeof(Number, suspect);
54
- };
9
+ is_typeof = function(type, suspect) {
10
+ if (is_undefined(type)) {
11
+ throw new SyntaxError("is_typeof(Type, suspect): type is undefined");
55
12
  }
56
-
57
- if (is_undefined(window.is_date)) {
58
- window.is_date = function(suspect) {
59
- return is_typeof(Date, suspect);
60
- };
13
+ if (is_undefined(suspect)) {
14
+ throw new SyntaxError("is_typeof(Type, suspect): suspect is undefined");
61
15
  }
62
16
 
63
- if (is_undefined(window.is_bool)) {
64
- window.is_bool = function(suspect) {
65
- return is_typeof(Boolean, suspect);
66
- };
67
- }
17
+ return (suspect.constructor == type) ? true : false;
18
+ };
68
19
 
69
- if (is_undefined(window.is_regex)) {
70
- window.is_regex = function(suspect) {
71
- return is_typeof(RegExp, suspect);
72
- };
20
+ is_numeric = function(suspect) {
21
+ if(is_typeof(Number, suspect)) {
22
+ return true;
73
23
  }
74
-
75
-
76
- if (is_undefined(window.is_empty)) {
77
- window.is_empty = function(suspect) {
78
- return suspect.length === 0;
79
- };
24
+ else {
25
+ var pattern = /^-?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;
26
+ return pattern.test(suspect);
80
27
  }
81
-
82
- if (is_undefined(window.is_not_empty)) {
83
- window.is_not_empty = function(suspect) {
84
- return suspect.length >= 1;
85
- };
28
+ };
29
+
30
+ is_string = function(suspect) {
31
+ return is_typeof(String, suspect);
32
+ };
33
+
34
+ is_array = function(suspect) {
35
+ return is_typeof(Array, suspect);
36
+ };
37
+
38
+ is_number = function(suspect) {
39
+ return is_typeof(Number, suspect);
40
+ };
41
+
42
+ is_date = function(suspect) {
43
+ return is_typeof(Date, suspect);
44
+ };
45
+
46
+ is_bool = function(suspect) {
47
+ return is_typeof(Boolean, suspect);
48
+ };
49
+
50
+ is_regex = function(suspect) {
51
+ return is_typeof(RegExp, suspect);
52
+ };
53
+
54
+ is_empty = function(suspect) {
55
+ return suspect.length === 0;
56
+ };
57
+
58
+ is_not_empty = function(suspect) {
59
+ return suspect.length >= 1;
60
+ };
61
+ unless = function(expression, callback, fallback) {
62
+ if (is_undefined(callback)) {
63
+ throw new SyntaxError("unless(expression, callback[, fallback]): callback is undefined");
86
64
  }
87
65
 
88
- if (is_undefined(Function.prototype['method'])) {
89
- Function.prototype.method = function(name, func) {
90
- if (is_undefined(name)) {
91
- throw new SyntaxError("Object.method(name, func): name is undefined");
92
- }
93
-
94
- if (is_undefined(func)) {
95
- throw new SyntaxError("Object.method(name, func): func is undefined");
96
- }
97
-
98
- if (is_undefined(this.prototype[name])) {
99
- this.prototype[name] = func;
100
- return this;
101
- }
102
- };
66
+ if (!!!expression) {
67
+ callback.call(this);
103
68
  }
104
-
105
- if (is_undefined(window.unless)) {
106
- window.unless = function(expression, callback, fallback) {
107
- if (is_undefined(expression)) {
108
- throw new SyntaxError("unless(expression, callback[, fallback]): expression is undefined");
109
- }
110
-
111
- if (is_undefined(callback)) {
112
- throw new SyntaxError("unless(expression, callback[, fallback]): callback is undefined");
113
- }
114
-
115
- if (!expression) {
116
- callback.call(this);
117
- }
118
- else if (is_defined(fallback)) {
119
- fallback.call(this);
120
- }
121
- };
122
- }
123
- if (is_undefined(Function.prototype['method'])) {
124
- Function.prototype.method = function(name, func) {
125
- if (is_undefined(name)) {
126
- throw new SyntaxError("Object.method(name, func): name is undefined");
127
- }
128
-
129
- if (is_undefined(func)) {
130
- throw new SyntaxError("Object.method(name, func): func is undefined");
131
- }
132
-
133
- if (is_undefined(this.prototype[name])) {
134
- this.prototype[name] = func;
135
- return this;
136
- }
137
- };
138
- }
139
-
140
- if (is_undefined(window.unless)) {
141
- window.unless = function(expression, callback, fallback) {
142
- if (is_undefined(expression)) {
143
- throw new SyntaxError("unless(expression, callback[, fallback]): expression is undefined");
144
- }
145
-
146
- if (is_undefined(callback)) {
147
- throw new SyntaxError("unless(expression, callback[, fallback]): callback is undefined");
148
- }
149
-
150
- if (!expression) {
151
- callback.call(this);
152
- }
153
- else if (is_defined(fallback)) {
154
- fallback.call(this);
155
- }
156
- };
69
+ else {
70
+ if (is_defined(fallback)) {
71
+ fallback.call(this);
72
+ }
157
73
  }
74
+ };
75
+ var dom = (function() {
158
76
  var userAgent = navigator.userAgent;
159
77
  var browser = {
160
78
  agent: userAgent,
161
- mozilla: (/mozilla/.test(userAgent.toLowerCase())) && (!/(compatible|webkit)/.test(userAgent.toLowerCase())),
79
+ mozilla: (/mozilla/.test(userAgent.toLowerCase())) && !(/(compatible|webkit)/.test(userAgent.toLowerCase())),
162
80
  webkit: /webkit/.test(userAgent.toLowerCase()),
163
81
  firefox: /firefox/.test(userAgent.toLowerCase()),
164
82
  chrome: /webkit/.test(userAgent.toLowerCase()),
165
83
  safari: /safari/.test(userAgent.toLowerCase()),
166
84
  opera: /opera/.test(userAgent.toLowerCase()),
167
- msie: (/msie/.test(userAgent.toLowerCase())) && (!/opera/.test( userAgent.toLowerCase() ))
85
+ msie: (/msie/.test(userAgent.toLowerCase())) && !(/opera/.test( userAgent.toLowerCase() ))
168
86
  };
169
87
 
170
88
  var readyBound = false;
@@ -184,23 +102,24 @@
184
102
  }
185
103
 
186
104
  function addLoadEvent(func) {
187
- var oldonload = window.onload;
188
- if (typeof window.onload != 'function') {
189
- window.onload = func;
190
- } else {
191
- window.onload = function() {
192
- if (oldonload) {
193
- oldonload();
194
- }
195
- func();
196
- }
197
- }
198
- };
105
+ var oldonload = window.onload;
106
+ if (typeof window.onload != 'function') {
107
+ window.onload = func;
108
+ }
109
+ else {
110
+ window.onload = function() {
111
+ if (oldonload) {
112
+ oldonload();
113
+ }
114
+ func();
115
+ };
116
+ }
117
+ }
199
118
 
200
119
  function bindReady() {
201
120
  if (readyBound) {
202
- return;
203
- }
121
+ return;
122
+ }
204
123
 
205
124
  readyBound = true;
206
125
 
@@ -208,46 +127,55 @@
208
127
  document.addEventListener("DOMContentLoaded", domReady, false);
209
128
  }
210
129
 
211
- if (browser.msie && window == top) (function(){
212
- if (isReady) return;
213
- try {
214
- document.documentElement.doScroll("left");
215
- } catch(error) {
216
- setTimeout(arguments.callee, 0);
217
- return;
218
- }
219
- domReady();
220
- })();
130
+ if (browser.msie && window == top) {
131
+ (function() {
132
+ if (isReady) {
133
+ return;
134
+ }
135
+ try {
136
+ document.documentElement.doScroll("left");
137
+ } catch(error) {
138
+ setTimeout(arguments.callee, 0);
139
+ return;
140
+ }
141
+ domReady();
142
+ })();
143
+ }
221
144
 
222
145
  if (browser.opera) {
223
146
  document.addEventListener( "DOMContentLoaded", function () {
224
- if (isReady) return;
225
- for (var i = 0; i < document.styleSheets.length; i++)
147
+ if (isReady) {
148
+ return;
149
+ }
150
+ for (var i = 0; i < document.styleSheets.length; i++) {
226
151
  if (document.styleSheets[i].disabled) {
227
152
  setTimeout( arguments.callee, 0 );
228
153
  return;
229
154
  }
230
- domReady();
155
+ domReady();
156
+ }
231
157
  }, false);
232
158
  }
233
159
 
234
160
  if (browser.safari) {
235
- var numStyles;
236
- (function(){
237
- if (isReady) return;
161
+ var numStyles;
162
+ (function() {
163
+ if (isReady) {
164
+ return;
165
+ }
238
166
  if (document.readyState != "loaded" && document.readyState != "complete") {
239
167
  setTimeout( arguments.callee, 0 );
240
168
  return;
241
169
  }
242
170
  if (numStyles === undefined) {
243
- var links = document.getElementsByTagName("link");
244
- for (var i=0; i < links.length; i++) {
245
- if (links[i].getAttribute('rel') == 'stylesheet') {
246
- numStyles++;
247
- }
248
- }
249
- var styles = document.getElementsByTagName("style");
250
- numStyles += styles.length;
171
+ var links = document.getElementsByTagName("link");
172
+ for (var i=0; i < links.length; i++) {
173
+ if (links[i].getAttribute('rel') == 'stylesheet') {
174
+ numStyles++;
175
+ }
176
+ }
177
+ var styles = document.getElementsByTagName("style");
178
+ numStyles += styles.length;
251
179
  }
252
180
  if (document.styleSheets.length != numStyles) {
253
181
  setTimeout( arguments.callee, 0 );
@@ -258,171 +186,112 @@
258
186
  })();
259
187
  }
260
188
 
261
- addLoadEvent(domReady);
262
- };
189
+ addLoadEvent(domReady);
190
+ }
263
191
 
264
- window.NinjsDOM = function() {
265
- this.cached_selectors = {};
192
+ return {
193
+ bind: bindReady,
194
+ is_ready: isReady,
195
+ ready_list: readyList
266
196
  };
197
+ })();
267
198
 
268
- NinjsDOM.method('ready', function(fn, args) {
269
- bindReady();
199
+ NinjsDOM = function() {
200
+ this.cached_selectors = {};
201
+ };
270
202
 
271
- if (isReady) {
272
- fn.call(window, []);
273
- }
274
- else {
275
- readyList.push( function() { return fn.call(window, []); } );
276
- }
277
- });
203
+ NinjsDOM.prototype.ready = function(fn, args) {
204
+ dom.bind();
278
205
 
279
- bindReady();
280
- window.NinjsModule = function(name) {
281
- this.dom = new NinjsDOM(this);
282
- this.browser = browser;
283
- this.data = {};
284
- this.name = name;
285
- this.run_tests = false;
286
- this.tests = [];
287
- };
288
-
289
- NinjsModule.method('actions', function() {});
206
+ if (dom.is_ready()) {
207
+ fn.call(window, args || []);
208
+ }
209
+ else {
210
+ dom.ready_list.push( function() { return fn.call(window, args || []); } );
211
+ }
212
+ };
290
213
 
291
- NinjsModule.method('run', function() {
292
- var mod = this;
293
- this.dom.ready(function() {
294
- mod.execute();
295
- });
296
- });
214
+ dom.bind();
215
+ NinjsModule = function(name) {
216
+ this.dom = new NinjsDOM(this);
217
+ this.data = {};
218
+ this.name = name;
219
+ };
297
220
 
298
- NinjsModule.method('execute', function() {
299
- if (this.run_tests) {
300
- this._run_tests();
301
- }
221
+ NinjsModule.prototype.actions = function() {};
302
222
 
303
- this.actions();
223
+ NinjsModule.prototype.run = function() {
224
+ var mod = this;
225
+ this.dom.ready(function() {
226
+ mod.execute();
304
227
  });
228
+ };
305
229
 
306
- NinjsModule.method('elements', function(elements) {
307
- if (is_undefined(elements)) {
308
- if (is_typeof(Object, elements)) {
309
- throw new SyntaxError("NinjsModule.elements(elements): elements is undefined");
310
- }
311
- else if (is_string(elements)) {
312
- throw new SyntaxError("NinjsModule.elements(name): name is undefined");
313
- }
314
- }
230
+ NinjsModule.prototype.execute = function() {
231
+ this.actions();
232
+ };
315
233
 
316
- if (is_string(elements)) {
317
- var name = elements;
318
- return this.dom.cached_selectors[name];
234
+ NinjsModule.prototype.elements = function(elements) {
235
+ if (is_undefined(elements)) {
236
+ if (is_typeof(Object, elements)) {
237
+ throw new SyntaxError("NinjsModule.elements(elements): elements is undefined");
319
238
  }
320
- else {
321
- var dom = this.dom;
322
- dom.ready(function() {
323
- for(var key in elements) {
324
- if (elements.hasOwnProperty(key)) {
325
- dom.cached_selectors[key] = elements[key];
326
- }
327
- }
328
- });
329
- }
330
- });
331
-
332
- NinjsModule.method('set_data', function(key, value) {
333
- if (is_undefined(key)) {
334
- throw new SyntaxError('NinjsModule.set_data(key, value): key is undefined');
335
- }
336
-
337
- if (is_typeof(String, key) && is_undefined(value)) {
338
- throw new SyntaxError('NinjsModule.set_data(key, value): value is undefined');
239
+ else if (is_string(elements)) {
240
+ throw new SyntaxError("NinjsModule.elements(name): name is undefined");
339
241
  }
242
+ }
340
243
 
341
- if (is_typeof(String, key)) {
342
- this.data[key] = value;
343
- }
344
- else if (is_typeof(Object, key)) {
345
- var data = key;
346
- for(var property in data) {
347
- this.data[property] = data[property];
244
+ if (is_string(elements)) {
245
+ var name = elements;
246
+ return this.dom.cached_selectors[name];
247
+ }
248
+ else {
249
+ var dom = this.dom;
250
+ dom.ready(function() {
251
+ for(var key in elements) {
252
+ if (elements.hasOwnProperty(key)) {
253
+ dom.cached_selectors[key] = elements[key];
254
+ }
348
255
  }
349
- }
350
-
351
- return this;
352
- });
256
+ });
257
+ }
258
+ };
353
259
 
354
- NinjsModule.method('add_test', function(test_file) {
355
- this.tests.push(test_file);
356
- });
260
+ NinjsModule.prototype.set_data = function(key, value) {
261
+ if (is_undefined(key)) {
262
+ throw new SyntaxError('NinjsModule.set_data(key, value): key is undefined');
263
+ }
357
264
 
358
- NinjsModule.method('_run_tests', function() {
359
- var test_template = [];
360
- test_template.push('<div class="test-results" title="Test Results">');
361
- test_template.push('<h1 id="qunit-header">' + this.name + ' module tests</h1>');
362
- test_template.push('<h2 id="qunit-banner"></h2>');
363
- test_template.push('<h2 id="qunit-userAgent"></h2>');
364
- test_template.push('<ol id="qunit-tests"></ol>');
365
- test_template.push('</div>');
366
-
367
- var qunit_dependencies = '<script src="' + _.tests_path +'qunit/qunit.js"></script>';
368
- $.getScript(_.tests_path + 'qunit/qunit.js');
369
- var qunit_styles = '<link rel="stylesheet" href="' + _.tests_path + 'qunit/qunit.css">';
370
- $('body').append(qunit_styles);
371
- $('body').append(test_template.join("\n"));
372
-
373
- this.tests.each(function(test) {
374
- $.getScript(_.tests_path + test + '.test.js', function() {
375
- var test_results_dialog = $('.test-results');
376
- var height = $(window).height() - 200;
377
- var width = $(window).width() - 300;
378
- try {
379
- test_results_dialog.dialog({
380
- width: width,
381
- height: height,
382
- autoOpen: false,
383
- buttons: {
384
- "Thanks buddy": function() {
385
- test_results_dialog.dialog('close');
386
- }
387
- }
388
- });
389
- var failed = $('.failed');
390
- console.log(failed.html());
391
- test_results_dialog.dialog('open');
392
- }
393
- catch(error) {
394
- alert("Test harness requires jQueryUI");
395
- }
396
- });
397
- });
398
- });
265
+ if (is_typeof(String, key) && is_undefined(value)) {
266
+ throw new SyntaxError('NinjsModule.set_data(key, value): value is undefined');
267
+ }
399
268
 
400
- window.NinjsApplication = function(base_url, tests_path) {
401
- if(is_defined(tests_path)) {
402
- this.tests_path = tests_path;
269
+ if (is_typeof(String, key)) {
270
+ this.data[key] = value;
271
+ }
272
+ else if (is_typeof(Object, key)) {
273
+ var data = key;
274
+ for(var property in data) {
275
+ this.data[property] = data[property];
403
276
  }
277
+ }
404
278
 
405
- if(is_defined(base_url)) {
406
- this.site_url = function(path) {
407
- var path = path || '';
408
- return base_url + path;
409
- };
410
- }
411
- };
279
+ return this;
280
+ };
281
+ NinjsApplication = function() {};
412
282
 
413
- NinjsApplication.method('add_module', function(name) {
414
- if (is_undefined(name)) {
415
- throw new SyntaxError("NinjsApplication.add_module(name): name is undefined");
416
- }
283
+ NinjsApplication.prototype.add_module = function(name) {
284
+ if (is_undefined(name)) {
285
+ throw new SyntaxError("NinjsApplication.add_module(name): name is undefined");
286
+ }
417
287
 
418
- if (is_defined(this[name])) {
419
- throw new SyntaxError("NinjsApplication.add_module(name): '" + name + "' already declared");
420
- }
288
+ if (is_defined(this[name])) {
289
+ throw new SyntaxError("NinjsApplication.add_module(name): '" + name + "' already declared");
290
+ }
421
291
 
422
- if (this.name === name) {
423
- throw new SyntaxError("NinjsApplication.add_module(name): a module cannot have the same name as the application");
424
- }
292
+ if (this.name === name) {
293
+ throw new SyntaxError("NinjsApplication.add_module(name): a module cannot have the same name as the application");
294
+ }
425
295
 
426
- return this[name] = new NinjsModule(name);
427
- });
428
- })();
296
+ return this[name] = new NinjsModule(name);
297
+ };