ninjs 0.13.7 → 0.13.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (275) hide show
  1. data/.bundle/config +2 -0
  2. data/CNAME +1 -0
  3. data/Gemfile +13 -0
  4. data/Gemfile.lock +36 -0
  5. data/LICENSE +29 -0
  6. data/README.md +348 -0
  7. data/VERSION +1 -1
  8. data/bin/ninjs +211 -0
  9. data/lib/ninjs.rb +10 -0
  10. data/lib/ninjs/command.rb +88 -0
  11. data/lib/ninjs/configuration.rb +82 -0
  12. data/lib/ninjs/dependencies.rb +16 -0
  13. data/lib/ninjs/generator.rb +57 -0
  14. data/lib/ninjs/helpers.rb +17 -0
  15. data/lib/ninjs/manifest.rb +9 -0
  16. data/lib/ninjs/notification.rb +37 -0
  17. data/lib/ninjs/project.rb +214 -0
  18. data/ninjs.gemspec +294 -5
  19. data/repository/jquery/1.1.4.js +2508 -0
  20. data/repository/jquery/1.2.6.js +32 -0
  21. data/repository/jquery/1.3.2.js +19 -0
  22. data/repository/jquery/1.4.2.js +154 -0
  23. data/repository/jquery/1.4.3.js +166 -0
  24. data/repository/jquery/1.4.4.js +167 -0
  25. data/repository/jquery/1.5.js +16 -0
  26. data/repository/jquery/fancybox/1.3.1.js +1079 -0
  27. data/repository/jquery/fancybox/assets/1.3.1/css/fancybox.css +363 -0
  28. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/blank.gif +0 -0
  29. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_close.png +0 -0
  30. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_loading.png +0 -0
  31. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_nav_left.png +0 -0
  32. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_nav_right.png +0 -0
  33. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_e.png +0 -0
  34. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_n.png +0 -0
  35. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_ne.png +0 -0
  36. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_nw.png +0 -0
  37. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_s.png +0 -0
  38. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_se.png +0 -0
  39. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_sw.png +0 -0
  40. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_w.png +0 -0
  41. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_left.png +0 -0
  42. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_main.png +0 -0
  43. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_over.png +0 -0
  44. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_right.png +0 -0
  45. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox-x.png +0 -0
  46. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox-y.png +0 -0
  47. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox.png +0 -0
  48. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/jquery.easing-1.3.pack.js +72 -0
  49. data/repository/jquery/fancybox/latest.js +1 -0
  50. data/repository/jquery/latest.js +1 -0
  51. data/repository/jquery/mobile/1.0a3.js +123 -0
  52. data/repository/jquery/mobile/1.0a3/assets/css/jquery.mobile.css +1652 -0
  53. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/ajax-loader.png +0 -0
  54. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/form-check-off.png +0 -0
  55. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/form-check-on.png +0 -0
  56. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/form-radio-off.png +0 -0
  57. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/form-radio-on.png +0 -0
  58. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icon-search-black.png +0 -0
  59. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icons-18-black.png +0 -0
  60. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icons-18-white.png +0 -0
  61. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icons-36-black.png +0 -0
  62. data/repository/jquery/mobile/1.0a3/assets/images/jquerymobile/icons-36-white.png +0 -0
  63. data/repository/jquery/mobile/latest.js +1 -0
  64. data/repository/jquery/mousewheel/3.0.2.js +11 -0
  65. data/repository/jquery/mousewheel/latest.js +1 -0
  66. data/repository/jquery/ui/1.8.7.js +783 -0
  67. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.accordion.css +19 -0
  68. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.all.css +11 -0
  69. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.autocomplete.css +53 -0
  70. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.base.css +11 -0
  71. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.button.css +38 -0
  72. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.core.css +41 -0
  73. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.datepicker.css +68 -0
  74. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.dialog.css +21 -0
  75. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.progressbar.css +11 -0
  76. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.resizable.css +20 -0
  77. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.selectable.css +10 -0
  78. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.slider.css +24 -0
  79. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.tabs.css +18 -0
  80. data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.theme.css +252 -0
  81. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  82. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  83. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  84. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  85. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_75_dadada_1x400.png +0 -0
  86. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  87. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  88. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  89. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_222222_256x240.png +0 -0
  90. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_2e83ff_256x240.png +0 -0
  91. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_454545_256x240.png +0 -0
  92. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_888888_256x240.png +0 -0
  93. data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_cd0a0a_256x240.png +0 -0
  94. data/repository/jquery/ui/latest.js +1 -0
  95. data/repository/json2.js +482 -0
  96. data/repository/modernizr/1.5.js +28 -0
  97. data/repository/modernizr/latest.js +1 -0
  98. data/repository/ninjs/core/.core.pdoc.yaml +0 -0
  99. data/repository/ninjs/core/.existence.pdoc.yaml +12 -0
  100. data/repository/ninjs/core/.extend.pdoc.yaml +0 -0
  101. data/repository/ninjs/core/.nin.pdoc.yaml +0 -0
  102. data/repository/ninjs/core/application.js +47 -0
  103. data/repository/ninjs/core/existence.js +277 -0
  104. data/repository/ninjs/core/extend.js +77 -0
  105. data/repository/ninjs/core/module.js +135 -0
  106. data/repository/ninjs/core/nin.js +4 -0
  107. data/repository/ninjs/docs/Data/ClassHierarchy.nd +0 -0
  108. data/repository/ninjs/docs/Data/ConfigFileInfo.nd +0 -0
  109. data/repository/ninjs/docs/Data/FileInfo.nd +16 -0
  110. data/repository/ninjs/docs/Data/ImageFileInfo.nd +0 -0
  111. data/repository/ninjs/docs/Data/ImageReferenceTable.nd +0 -0
  112. data/repository/ninjs/docs/Data/IndexInfo.nd +0 -0
  113. data/repository/ninjs/docs/Data/PreviousMenuState.nd +0 -0
  114. data/repository/ninjs/docs/Data/PreviousSettings.nd +0 -0
  115. data/repository/ninjs/docs/Data/SymbolTable.nd +0 -0
  116. data/repository/ninjs/docs/Languages.txt +113 -0
  117. data/repository/ninjs/docs/Menu.txt +63 -0
  118. data/repository/ninjs/docs/Topics.txt +81 -0
  119. data/repository/ninjs/docs/files/core/application-js.html +44 -0
  120. data/repository/ninjs/docs/files/core/existence-js.html +60 -0
  121. data/repository/ninjs/docs/files/core/extend-js.html +55 -0
  122. data/repository/ninjs/docs/files/core/module-js.html +80 -0
  123. data/repository/ninjs/docs/files/core/nin-js.html +38 -0
  124. data/repository/ninjs/docs/index.html +1 -0
  125. data/repository/ninjs/docs/index/Classes.html +33 -0
  126. data/repository/ninjs/docs/index/Files.html +45 -0
  127. data/repository/ninjs/docs/index/Functions.html +65 -0
  128. data/repository/ninjs/docs/index/General.html +85 -0
  129. data/repository/ninjs/docs/index/Variables.html +45 -0
  130. data/repository/ninjs/docs/javascript/main.js +841 -0
  131. data/repository/ninjs/docs/javascript/prettify.js +1526 -0
  132. data/repository/ninjs/docs/javascript/searchdata.js +152 -0
  133. data/repository/ninjs/docs/search/ClassesN.html +20 -0
  134. data/repository/ninjs/docs/search/FilesA.html +20 -0
  135. data/repository/ninjs/docs/search/FilesE.html +20 -0
  136. data/repository/ninjs/docs/search/FilesM.html +20 -0
  137. data/repository/ninjs/docs/search/FilesN.html +20 -0
  138. data/repository/ninjs/docs/search/FunctionsA.html +20 -0
  139. data/repository/ninjs/docs/search/FunctionsC.html +20 -0
  140. data/repository/ninjs/docs/search/FunctionsE.html +20 -0
  141. data/repository/ninjs/docs/search/FunctionsI.html +20 -0
  142. data/repository/ninjs/docs/search/FunctionsM.html +20 -0
  143. data/repository/ninjs/docs/search/FunctionsR.html +20 -0
  144. data/repository/ninjs/docs/search/FunctionsS.html +20 -0
  145. data/repository/ninjs/docs/search/FunctionsSymbols.html +20 -0
  146. data/repository/ninjs/docs/search/FunctionsU.html +20 -0
  147. data/repository/ninjs/docs/search/GeneralA.html +20 -0
  148. data/repository/ninjs/docs/search/GeneralC.html +20 -0
  149. data/repository/ninjs/docs/search/GeneralD.html +20 -0
  150. data/repository/ninjs/docs/search/GeneralE.html +20 -0
  151. data/repository/ninjs/docs/search/GeneralF.html +20 -0
  152. data/repository/ninjs/docs/search/GeneralI.html +20 -0
  153. data/repository/ninjs/docs/search/GeneralM.html +20 -0
  154. data/repository/ninjs/docs/search/GeneralN.html +20 -0
  155. data/repository/ninjs/docs/search/GeneralR.html +20 -0
  156. data/repository/ninjs/docs/search/GeneralS.html +20 -0
  157. data/repository/ninjs/docs/search/GeneralSymbols.html +20 -0
  158. data/repository/ninjs/docs/search/GeneralT.html +20 -0
  159. data/repository/ninjs/docs/search/GeneralU.html +20 -0
  160. data/repository/ninjs/docs/search/GeneralV.html +20 -0
  161. data/repository/ninjs/docs/search/NoResults.html +15 -0
  162. data/repository/ninjs/docs/search/VariablesD.html +20 -0
  163. data/repository/ninjs/docs/search/VariablesN.html +20 -0
  164. data/repository/ninjs/docs/search/VariablesR.html +20 -0
  165. data/repository/ninjs/docs/search/VariablesT.html +20 -0
  166. data/repository/ninjs/docs/styles/main.css +828 -0
  167. data/repository/ninjs/extensions/jquery.elements.js +60 -0
  168. data/repository/ninjs/tests/index.html +21 -0
  169. data/repository/ninjs/tests/ninjs.test.js +188 -0
  170. data/repository/ninjs/tests/ninjs.utilities.test.js +137 -0
  171. data/repository/ninjs/tests/qunit/qunit.css +197 -0
  172. data/repository/ninjs/tests/qunit/qunit.js +1415 -0
  173. data/repository/ninjs/utilities/all.js +5 -0
  174. data/repository/ninjs/utilities/array.js +29 -0
  175. data/repository/ninjs/utilities/cookie.js +0 -0
  176. data/repository/ninjs/utilities/css.js +51 -0
  177. data/repository/ninjs/utilities/number.js +11 -0
  178. data/repository/ninjs/utilities/string.js +61 -0
  179. data/repository/nullconsole.js +7 -0
  180. data/repository/qunit/assets/css/qunit.css +196 -0
  181. data/repository/qunit/qunit.js +1374 -0
  182. data/repository/selectivizr/1.0.js +5 -0
  183. data/repository/selectivizr/latest.js +1 -0
  184. data/repository/syntaxhighlighter/all.js +11 -0
  185. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCore.css +226 -0
  186. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDefault.css +328 -0
  187. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDjango.css +331 -0
  188. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEclipse.css +339 -0
  189. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEmacs.css +324 -0
  190. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreFadeToGrey.css +328 -0
  191. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMDUltra.css +324 -0
  192. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMidnight.css +324 -0
  193. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreRDark.css +324 -0
  194. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDefault.css +117 -0
  195. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDjango.css +120 -0
  196. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEclipse.css +128 -0
  197. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEmacs.css +113 -0
  198. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeFadeToGrey.css +117 -0
  199. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMDUltra.css +113 -0
  200. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMidnight.css +113 -0
  201. data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeRDark.css +113 -0
  202. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCore.scss +216 -0
  203. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDefault.scss +2 -0
  204. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDjango.scss +2 -0
  205. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEclipse.scss +2 -0
  206. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEmacs.scss +2 -0
  207. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreFadeToGrey.scss +2 -0
  208. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMDUltra.scss +2 -0
  209. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMidnight.scss +2 -0
  210. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreRDark.scss +2 -0
  211. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDefault.scss +7 -0
  212. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDjango.scss +36 -0
  213. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEclipse.scss +48 -0
  214. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEmacs.scss +32 -0
  215. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeFadeToGrey.scss +36 -0
  216. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMDUltra.scss +32 -0
  217. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMidnight.scss +32 -0
  218. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeRDark.scss +32 -0
  219. data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_theme_template.scss +120 -0
  220. data/repository/syntaxhighlighter/shAutoloader.js +17 -0
  221. data/repository/syntaxhighlighter/shBrushAS3.js +59 -0
  222. data/repository/syntaxhighlighter/shBrushAppleScript.js +75 -0
  223. data/repository/syntaxhighlighter/shBrushBash.js +59 -0
  224. data/repository/syntaxhighlighter/shBrushCSharp.js +65 -0
  225. data/repository/syntaxhighlighter/shBrushColdFusion.js +100 -0
  226. data/repository/syntaxhighlighter/shBrushCpp.js +97 -0
  227. data/repository/syntaxhighlighter/shBrushCss.js +91 -0
  228. data/repository/syntaxhighlighter/shBrushDelphi.js +55 -0
  229. data/repository/syntaxhighlighter/shBrushDiff.js +41 -0
  230. data/repository/syntaxhighlighter/shBrushErlang.js +52 -0
  231. data/repository/syntaxhighlighter/shBrushGroovy.js +67 -0
  232. data/repository/syntaxhighlighter/shBrushJScript.js +52 -0
  233. data/repository/syntaxhighlighter/shBrushJava.js +57 -0
  234. data/repository/syntaxhighlighter/shBrushJavaFX.js +58 -0
  235. data/repository/syntaxhighlighter/shBrushPerl.js +72 -0
  236. data/repository/syntaxhighlighter/shBrushPhp.js +88 -0
  237. data/repository/syntaxhighlighter/shBrushPlain.js +33 -0
  238. data/repository/syntaxhighlighter/shBrushPowerShell.js +74 -0
  239. data/repository/syntaxhighlighter/shBrushPython.js +64 -0
  240. data/repository/syntaxhighlighter/shBrushRuby.js +55 -0
  241. data/repository/syntaxhighlighter/shBrushSass.js +94 -0
  242. data/repository/syntaxhighlighter/shBrushScala.js +51 -0
  243. data/repository/syntaxhighlighter/shBrushSql.js +66 -0
  244. data/repository/syntaxhighlighter/shBrushVb.js +56 -0
  245. data/repository/syntaxhighlighter/shBrushXml.js +69 -0
  246. data/repository/syntaxhighlighter/shCore.js +17 -0
  247. data/repository/syntaxhighlighter/shLegacy.js +17 -0
  248. data/spec/command_spec.rb +9 -0
  249. data/spec/configuration_spec.rb +70 -0
  250. data/spec/dependencies_spec.rb +27 -0
  251. data/spec/fixtures/autoload.js +3 -0
  252. data/spec/fixtures/changed.ninjs.conf +6 -0
  253. data/spec/fixtures/compressed.myapp.js +39 -0
  254. data/spec/fixtures/core.js +6 -0
  255. data/spec/fixtures/dependencies.js +3 -0
  256. data/spec/fixtures/foo.elements.js +3 -0
  257. data/spec/fixtures/foo.js +17 -0
  258. data/spec/fixtures/foo.model.js +3 -0
  259. data/spec/fixtures/foo.module.js +13 -0
  260. data/spec/fixtures/hello.elements.js +3 -0
  261. data/spec/fixtures/hello.js +17 -0
  262. data/spec/fixtures/hello.model.js +3 -0
  263. data/spec/fixtures/hello.module.js +13 -0
  264. data/spec/fixtures/myapp.initial.js +535 -0
  265. data/spec/fixtures/myapp.js +710 -0
  266. data/spec/fixtures/new.ninjs.conf +6 -0
  267. data/spec/fixtures/ninjs.conf +6 -0
  268. data/spec/generator_spec.rb +34 -0
  269. data/spec/helpers_spec.rb +11 -0
  270. data/spec/manifest_spec.rb +8 -0
  271. data/spec/ninjs_spec.rb +20 -0
  272. data/spec/notification_spec.rb +27 -0
  273. data/spec/project_spec.rb +239 -0
  274. data/spec/spec_helper.rb +29 -0
  275. metadata +294 -50
@@ -0,0 +1,60 @@
1
+ (function($) {
2
+ NinjsModule.prototype.elements = function(elements, force) {
3
+ var self = this;
4
+
5
+ unless(is_defined(force), function() {
6
+ force = false;
7
+ });
8
+
9
+ if (is_string(elements)) {
10
+ var key = elements;
11
+ if (is_undefined(self.dom[key])) {
12
+ throw new SyntaxError("NinjsModule.elements('" + key + "'): " + self.name + ".dom." + key + " is undefined");
13
+ }
14
+
15
+ if (is_string(self.dom[key])) {
16
+ var selection = $(self.dom[key]);
17
+
18
+ unless(selection.length === 0, function() {
19
+ return self.dom[key] = selection;
20
+ }, function() {
21
+ return self.dom[key];
22
+ });
23
+ }
24
+ else {
25
+ if (self.dom[key].length === 0 || force) {
26
+
27
+ var return_obj = undefined;
28
+
29
+ if (is_string(force)) {
30
+ var selector = self.dom[key].selector;
31
+ self.dom[key] = $(force).find(selector);
32
+ self.dom[key].selector = selector;
33
+
34
+ return_obj = self.dom[key];
35
+ }
36
+
37
+ var selection = $(self.dom[key].selector);
38
+
39
+ unless(selection.length === 0, function() {
40
+ return_obj = selection;
41
+ });
42
+
43
+ return return_obj;
44
+ }
45
+ else {
46
+ return self.dom[key];
47
+ }
48
+ }
49
+ }
50
+ else if (is_typeof(Object, elements)) {
51
+ self.call_on_ready(function() {
52
+ for(var key in elements) {
53
+ if (elements.hasOwnProperty(key)) {
54
+ self.dom[key] = elements[key];
55
+ }
56
+ }
57
+ });
58
+ }
59
+ };
60
+ })(jQuery);
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <head>
3
+ <title>All Ninjs tests</title>
4
+
5
+ <link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen"/>
6
+
7
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
8
+ <script src="qunit/qunit.js"></script>
9
+
10
+ <script src="../lib/nin.js"></script>
11
+ <script src="../lib/utilities.js"></script>
12
+
13
+ <script src="ninjs.test.js"></script>
14
+ <script src="ninjs.utilities.test.js"></script>
15
+ </head>
16
+ <body>
17
+ <h1 id="qunit-header">Ninjs tests</h1>
18
+ <h2 id="qunit-banner"></h2>
19
+ <h2 id="qunit-userAgent"></h2>
20
+ <ol id="qunit-tests"></ol>
21
+ </body>
@@ -0,0 +1,188 @@
1
+ module("existence tests");
2
+
3
+ test("existence sanity check", function() {
4
+ ok(is_defined !== undefined, 'is_defined is defined');
5
+ ok(is_undefined !== undefined, 'is_undefined is defined');
6
+ ok(is_typeof !== undefined, 'is_typeof is defined');
7
+ });
8
+
9
+ test("can test for existence", function() {
10
+ var nonexistent;
11
+ var existent = 'I think';
12
+ equals(is_defined(existent), true, 'existent variable is_defined');
13
+ equals(is_defined(nonexistent), false, 'non-existent variable does not exist');
14
+ });
15
+
16
+ test("can test for non-existence", function() {
17
+ var existent = 'I think';
18
+ var nonexistent;
19
+ equals(is_undefined(nonexistent), true, 'non-existent variable does not exist');
20
+ equals(is_undefined(existent), false, 'existent variable does exist');
21
+ });
22
+
23
+ test("can check the type strictly with is_typeof", function() {
24
+ var foo = function(){};
25
+ var bar = {
26
+ name: 'SomeObject',
27
+ method: function() {}
28
+ };
29
+ var SomeClass = function(){};
30
+ var some_instance = new SomeClass();
31
+ equals(is_typeof(Number, 4), true, 'can check against Number');
32
+ equals(is_typeof(String, 'Hello World'), true, 'can check against String');
33
+ equals(is_typeof(Array, ['one', 'two', 'three']), true, 'can check against Array');
34
+ equals(is_typeof(Function, foo), true, 'can check against Function');
35
+ equals(is_typeof(Object, bar), true, 'can check against Object');
36
+ equals(is_typeof(RegExp, /pattern/), true, 'can check against Regexp');
37
+ equals(is_typeof(SomeClass, some_instance), true, 'can check against custom object');
38
+ });
39
+
40
+ module("typeof proxys");
41
+
42
+ test("can check for default types", function() {
43
+ var today = new Date();
44
+ var easy_as = [1,2,3];
45
+ var pattern = new RegExp(/pattern/);
46
+
47
+ ok(is_string('hello'), 'hello is_string');
48
+ ok(is_number(42), '42 is_number');
49
+ ok(is_array(easy_as), 'easy_as is_array');
50
+ ok(is_bool(false), 'false is_bool');
51
+ ok(is_date(today), 'today is_date');
52
+ ok(is_regex(pattern), 'pattern is_regex');
53
+
54
+ equals(is_regex('hello'), false, 'hello fails is_regex');
55
+ equals(is_date(42), false, '42 fails is_date');
56
+ equals(is_bool(easy_as), false, 'easy_as fails is_bool');
57
+ equals(is_array(today), false, 'today fails is_array');
58
+ equals(is_number(true), false, 'true fails is_number');
59
+ equals(is_string(pattern), false, 'pattern fails is_string');
60
+ });
61
+
62
+ test("can determine a number", function() {
63
+ ok(is_numeric(2), '2 is a number');
64
+ ok(is_numeric(-2), '-2 is a number');
65
+ ok(is_numeric(45.6), '45.6 is a number');
66
+ ok(is_numeric(-45.6), '-45.6 is a number');
67
+ equals(is_numeric('45.6'), true, "'45.6 is a number'");
68
+ equals(is_numeric('Hello'), false, 'Hello is not a number');
69
+ });
70
+
71
+ module("extend tests");
72
+
73
+ test("can add a method to the prototype", function() {
74
+ ok(is_defined(Function.prototype.method), "Object.prototype.method is defined");
75
+
76
+ String.method('test_method', function() {
77
+ return 'This is a test';
78
+ });
79
+
80
+ equals('Hello'.test_method(), 'This is a test', 'can create a prototype method with method');
81
+ });
82
+
83
+ test("can test a condition with unless", function() {
84
+ var is_true = false;
85
+
86
+ unless (false,
87
+ function() {
88
+ is_true = true;
89
+ }
90
+ );
91
+
92
+ ok(is_true, "unless works");
93
+
94
+ var does_fallback_work = false;
95
+
96
+ unless (true,
97
+ function() {
98
+
99
+ },
100
+ function() {
101
+ does_fallback_work = true;
102
+ }
103
+ );
104
+
105
+ ok(does_fallback_work, 'fallback works');
106
+ });
107
+
108
+ module("Ninjs application tests");
109
+
110
+ test("can create a ninjs application object", function() {
111
+ var testapp = new NinjsApplication();
112
+ ok(is_defined(testapp), 'testapp is defined');
113
+ ok(is_typeof(NinjsApplication, testapp), 'testapp is a valid NinjsApplication');
114
+ });
115
+
116
+ test("can create a NinjsModule", function() {
117
+ var testapp = new NinjsApplication();
118
+ testapp.add_module('testmodule');
119
+ ok(is_defined(testapp.testmodule), 'testapp.testmodule is defined');
120
+ ok(is_typeof(NinjsModule, testapp.testmodule), 'testapp.testmodule is a valid NinjsModule');
121
+ });
122
+
123
+ module('Ninjs Module tests');
124
+
125
+ test("module defaults", function() {
126
+ var testapp = new NinjsApplication();
127
+ testapp.add_module('testmodule');
128
+
129
+ // properties
130
+ ok(is_defined(testapp.testmodule.run_tests), 'testapp.testmodule.run_tests is defined');
131
+ equals(testapp.testmodule.run_tests, false, 'testapp.testmodule.run_tests defaults to false');
132
+ ok(is_defined(testapp.testmodule.data), "testapp.testmodule.data is defined");
133
+ ok(is_defined(testapp.testmodule.name), 'testapp.testmodule.name is defined');
134
+ equals(testapp.testmodule.name, 'testmodule', 'testapp.testmodule.name is correct');
135
+ ok(is_defined(testapp.testmodule.tests), 'testapp.testmodule.tests is defined');
136
+ ok(is_array(testapp.testmodule.tests), 'testapp.testmodule.tests is_array');
137
+ ok(testapp.testmodule.tests.is_empty(), 'testapp.testmodule.tests is empty');
138
+ ok(is_defined(app), 'app is defined');
139
+
140
+ // methods
141
+ ok(is_defined(testapp.testmodule.actions), 'testapp.testmodule.actions is defined');
142
+ ok(is_typeof(Function, testapp.testmodule.actions), "testapp.testmodule.actions is a valid Function");
143
+ ok(is_defined(testapp.testmodule.run), 'testapp.testmodule.run is defined');
144
+ ok(is_typeof(Function, testapp.testmodule.run), "testapp.testmodule.run is a valid Function");
145
+ ok(is_defined(testapp.testmodule.call_on_ready), 'testmodule.testapp.call_on_ready is defined');
146
+ ok(is_defined(testapp.testmodule.execute), 'testmodule.testapp.execute is defined');
147
+ ok(is_defined(testapp.testmodule.elements), 'testapp.testmodule.elements is defined');
148
+ ok(is_defined(testapp.testmodule.set_data), 'testapp.testmodule.set_data is defined');
149
+ });
150
+
151
+ test("add_module returns the created module", function() {
152
+ var testapp = new NinjsApplication();
153
+ var module = testapp.add_module('some_module');
154
+ equals(module, testapp.some_module, 'hey');
155
+ });
156
+
157
+ // Qunit waits for DOM to load before running tests
158
+ // to test DOM wait feature, we need to run some code outside the tests
159
+ (function() {
160
+ var testapp = new NinjsApplication();
161
+ testapp.add_module('testmodule');
162
+ testapp.testmodule.actions = function() {
163
+ // append an element to be sure the DOM is ready for manipulation and test for the element's existence
164
+ $('body').append('<div id="made-by-actions"/>');
165
+
166
+ test("Ninjs module can run actions", function() {
167
+ equals($('#made-by-actions').length, 1,'testapp.test.actions ran after DOM was ready');
168
+ });
169
+ };
170
+
171
+ testapp.testmodule.run();
172
+ }());
173
+
174
+ // Qunit waits for DOM to load before running tests
175
+ // to test DOM wait feature, we need to run some code outside the tests
176
+ (function() {
177
+ var testapp = new NinjsApplication();
178
+ testapp.add_module('testmodule');
179
+ testapp.testmodule.elements(function() {
180
+ testapp.testmodule.qunit_header = $('#qunit-header');
181
+ testapp.testmodule.qunit_banner = $('#qunit-banner');
182
+
183
+ test('Ninjs module can cache elements', function() {
184
+ equals(testapp.testmodule.qunit_header[0].tagName, 'H1', '#qunit-header returns an h1');
185
+ equals(testapp.testmodule.qunit_banner[0].tagName, 'H2', '#qunit-banner returns an h2');
186
+ });
187
+ });
188
+ }());
@@ -0,0 +1,137 @@
1
+ module("array utility tests");
2
+
3
+ test("can test for emptiness", function() {
4
+ expect(4);
5
+
6
+ ok([].is_empty(), "[].is_empty() is true");
7
+ equals(['one', 'two', 'three'].is_empty(), false, "['one', 'two', 'three'].is_empty()");
8
+ ok(['one', 'two', 'three'].not_empty(), "['one', 'two', 'three'].not_empty() is false");
9
+ equals([].not_empty(), false, "[].not_empty() is false");
10
+ });
11
+
12
+ test("can iterate over each element", function() {
13
+ expect(7);
14
+
15
+ var iteration_count = 0;
16
+ var test_array_values = [];
17
+ var test_array_indices = [];
18
+
19
+ ['one', 'two', 'three'].each(function(value, index) {
20
+ iteration_count++;
21
+ test_array_values.push(value);
22
+ test_array_indices.push(index);
23
+ });
24
+
25
+ equals(test_array_values[0], 'one', 'value at index 0 is correct');
26
+ equals(test_array_values[1], 'two', 'value at index 1 is correct');
27
+ equals(test_array_values[2], 'three', 'value at index 2 is correct');
28
+
29
+ equals(test_array_indices[0], 0, 'first index is correct');
30
+ equals(test_array_indices[1], 1, 'second index is correct');
31
+ equals(test_array_indices[2], 2, 'third index is correct');
32
+
33
+ equals(iteration_count, 3, 'made only three iterations');
34
+ });
35
+
36
+ test("can test if an array contains an element", function() {
37
+ var array = ['one', 'two', 'three'];
38
+ var string = 'hello';
39
+ var object = {
40
+ name: 'some object'
41
+ };
42
+ var number = 45;
43
+ var date = new Date();
44
+
45
+ var test_array = [array, string, object, number, date];
46
+
47
+ ok(test_array.contains(array), 'array.contains(array)');
48
+ ok(test_array.contains(string), 'array.contains(string)');
49
+ ok(test_array.contains(object), 'array.contains(object)');
50
+ ok(test_array.contains(number), 'array.contains(number)');
51
+ ok(test_array.contains(date), 'array.contains(date)');
52
+ equals(test_array.contains('not in there'), false, 'non-existent value is false');
53
+ });
54
+
55
+ module("string utility tests");
56
+
57
+ test("can test for emptiness", function() {
58
+ ok(''.is_empty(), "''.is_empty() is true");
59
+ equals('hey there'.is_empty(), false, "'hey there'.is_empty() is false");
60
+ ok('hey there'.not_empty(), "'hey there'.not_empty() is false");
61
+ equals(''.not_empty(), false, "''.not_empty() is false");
62
+ });
63
+
64
+ test('can test for number', function() {
65
+ equals('34'.is_numeric(), true, "34 is numeric");
66
+ equals('0.5'.is_numeric(), true, ".5 is numeric");
67
+ equals('-34'.is_numeric(), true, '-34 is numeric');
68
+ equals('-0.5'.is_numeric(), true, '-.05 is numeric');
69
+ equals('hello'.is_numeric(), false, 'hello is numeric');
70
+ });
71
+
72
+ test('can trim a string', function() {
73
+ equals(' hello '.trim(), 'hello', "' hello '.trim()");
74
+ equals(' hello '.ltrim(), 'hello ', "' hello '.ltrim()");
75
+ equals(' hello '.rtrim(), ' hello', "' hello '.rtrim()");
76
+ });
77
+
78
+ test("can iterate over each character", function() {
79
+ var iteration_count = 0;
80
+ var test_chars = [];
81
+ var test_indices = [];
82
+ '123'.each(function(character, index) {
83
+ test_chars.push(character);
84
+ test_indices.push(index);
85
+ iteration_count++;
86
+ });
87
+
88
+ equals(test_chars[0], '1', 'first character of 123 is 1');
89
+ equals(test_chars[1], '2', 'second character of 123 is 2');
90
+ equals(test_chars[2], '3', 'second character of 123 is 3');
91
+
92
+ equals(test_indices[0], 0, 'first index is correct');
93
+ equals(test_indices[1], 1, 'second index is correct');
94
+ equals(test_indices[2], 2, 'third index is correct');
95
+
96
+ equals(iteration_count, 3, 'made only three iterations');
97
+ });
98
+
99
+ test('can capitalize a string', function() {
100
+ equals('hello world'.capitalize(), 'Hello world', 'capitalized string correctly');
101
+ });
102
+
103
+ test('can reverse a string', function() {
104
+ equals('hello world'.reverse(), 'dlrow olleh', 'reversed string correctly');
105
+ equals('satan oscillate my metallic sonatas'.reverse(), 'satanos cillatem ym etallicso natas', 'fucking palindromes, how do they work?');
106
+ });
107
+
108
+ test("can convert to number", function() {
109
+ var whole_number = '32';
110
+ var decimal = '0.08';
111
+ var negative_number = '-32';
112
+ var negative_float = '-0.08';
113
+
114
+ same(whole_number.to_n(), 32, "whole_number.to_n() is 32");
115
+ same(decimal.to_n(), 0.08, "decimal.to_n() is 0.08");
116
+ same(negative_number.to_n(), -32, "negative_number.to_n() is -32");
117
+ same(negative_float.to_n(), -0.08, "negative_float.to_n() -0.08");
118
+ });
119
+
120
+ test("can pluck a string", function() {
121
+ equals('one, two, three'.pluck(','), 'one two three', "'one, two, three'.pluck(',')");
122
+ });
123
+
124
+ test("can single space a string", function() {
125
+ var hard_space = 'one&nbsp;two&nbsp;&nbsp;three&nbsp;&nbsp;&nbsp;four&nbsp;&nbsp;&nbsp;&nbsp;five&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;six';
126
+ var soft_space = 'one two three four five six';
127
+ var mixed_space = 'one two &nbsp; three &nbsp;&nbsp;four &nbsp;&nbsp;&nbsp;five &nbsp;&nbsp;&nbsp;&nbsp;six';
128
+
129
+ equals(hard_space.single_space(), 'one two three four five six', 'correctly spaced &nbsp;');
130
+ equals(soft_space.single_space(), 'one two three four five six', "correctly spaced soft spaces");
131
+ equals(mixed_space.single_space(), 'one two three four five six', "correctly spaced mixed spaces");
132
+ });
133
+
134
+ test("can compress a string", function() {
135
+ var string = "satan\n\t oscillate\n\t my\n\t metallic\n sonatas";
136
+ same(string.compress(), 'satanoscillatemymetallicsonatas', "string is compressed correctly");
137
+ });
@@ -0,0 +1,197 @@
1
+ /** Font Family and Sizes */
2
+
3
+ #qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
4
+ font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
5
+ }
6
+
7
+ #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
8
+ #qunit-tests { font-size: smaller; }
9
+
10
+
11
+ /** Resets */
12
+
13
+ #qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
14
+ margin: 0;
15
+ padding: 0;
16
+ }
17
+
18
+
19
+ /** Header */
20
+
21
+ #qunit-header {
22
+ padding: 0.5em 0 0.5em 1em;
23
+
24
+ color: #8699a4;
25
+ background-color: #0d3349;
26
+
27
+ font-size: 1.5em;
28
+ line-height: 1em;
29
+ font-weight: normal;
30
+
31
+ border-radius: 15px 15px 0 0;
32
+ -moz-border-radius: 15px 15px 0 0;
33
+ -webkit-border-top-right-radius: 15px;
34
+ -webkit-border-top-left-radius: 15px;
35
+ }
36
+
37
+ #qunit-header a {
38
+ text-decoration: none;
39
+ color: #c2ccd1;
40
+ }
41
+
42
+ #qunit-header a:hover,
43
+ #qunit-header a:focus {
44
+ color: #fff;
45
+ }
46
+
47
+ #qunit-banner {
48
+ height: 5px;
49
+ }
50
+
51
+ #qunit-testrunner-toolbar {
52
+ padding: 0.5em 0 0.5em 2em;
53
+ color: #5E740B;
54
+ background-color: #eee;
55
+ }
56
+
57
+ #qunit-userAgent {
58
+ padding: 0.5em 0 0.5em 2.5em;
59
+ background-color: #2b81af;
60
+ color: #fff;
61
+ text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
62
+ }
63
+
64
+
65
+ /** Tests: Pass/Fail */
66
+
67
+ #qunit-tests {
68
+ list-style-position: inside;
69
+ }
70
+
71
+ #qunit-tests li {
72
+ padding: 0.4em 0.5em 0.4em 2.5em;
73
+ border-bottom: 1px solid #fff;
74
+ list-style-position: inside;
75
+ }
76
+
77
+ #qunit-tests li strong {
78
+ cursor: pointer;
79
+ }
80
+
81
+ #qunit-tests ol {
82
+ margin-top: 0.5em;
83
+ padding: 0.5em;
84
+
85
+ background-color: #fff;
86
+
87
+ border-radius: 15px;
88
+ -moz-border-radius: 15px;
89
+ -webkit-border-radius: 15px;
90
+
91
+ box-shadow: inset 0px 2px 13px #999;
92
+ -moz-box-shadow: inset 0px 2px 13px #999;
93
+ -webkit-box-shadow: inset 0px 2px 13px #999;
94
+ }
95
+
96
+ #qunit-tests table {
97
+ border-collapse: collapse;
98
+ margin-top: .2em;
99
+ }
100
+
101
+ #qunit-tests th {
102
+ text-align: right;
103
+ vertical-align: top;
104
+ padding: 0 .5em 0 0;
105
+ }
106
+
107
+ #qunit-tests td {
108
+ vertical-align: top;
109
+ }
110
+
111
+ #qunit-tests pre {
112
+ margin: 0;
113
+ white-space: pre-wrap;
114
+ word-wrap: break-word;
115
+ }
116
+
117
+ #qunit-tests del {
118
+ background-color: #e0f2be;
119
+ color: #374e0c;
120
+ text-decoration: none;
121
+ }
122
+
123
+ #qunit-tests ins {
124
+ background-color: #ffcaca;
125
+ color: #500;
126
+ text-decoration: none;
127
+ }
128
+
129
+ /*** Test Counts */
130
+
131
+ #qunit-tests b.counts { color: black; }
132
+ #qunit-tests b.passed { color: #5E740B; }
133
+ #qunit-tests b.failed { color: #710909; }
134
+
135
+ #qunit-tests li li {
136
+ margin: 0.5em;
137
+ padding: 0.4em 0.5em 0.4em 0.5em;
138
+ background-color: #fff;
139
+ border-bottom: none;
140
+ list-style-position: inside;
141
+ }
142
+
143
+ /*** Passing Styles */
144
+
145
+ #qunit-tests li li.pass {
146
+ color: #5E740B;
147
+ background-color: #fff;
148
+ border-left: 26px solid #C6E746;
149
+ }
150
+
151
+ #qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
152
+ #qunit-tests .pass .test-name { color: #366097; }
153
+
154
+ #qunit-tests .pass .test-actual,
155
+ #qunit-tests .pass .test-expected { color: #999999; }
156
+
157
+ #qunit-banner.qunit-pass { background-color: #C6E746; }
158
+
159
+ /*** Failing Styles */
160
+
161
+ #qunit-tests li li.fail {
162
+ color: #710909;
163
+ background-color: #fff;
164
+ border-left: 26px solid #EE5757;
165
+ }
166
+
167
+ #qunit-tests .fail { color: #000000; background-color: #EE5757; }
168
+ #qunit-tests .fail .test-name,
169
+ #qunit-tests .fail .module-name { color: #000000; }
170
+
171
+ #qunit-tests .fail .test-actual { color: #EE5757; }
172
+ #qunit-tests .fail .test-expected { color: green; }
173
+
174
+ #qunit-banner.qunit-fail { background-color: #EE5757; }
175
+
176
+
177
+ /** Footer */
178
+
179
+ #qunit-testresult {
180
+ padding: 0.5em 0.5em 0.5em 2.5em;
181
+
182
+ color: #2b81af;
183
+ background-color: #D2E0E6;
184
+
185
+ border-radius: 0 0 15px 15px;
186
+ -moz-border-radius: 0 0 15px 15px;
187
+ -webkit-border-bottom-right-radius: 15px;
188
+ -webkit-border-bottom-left-radius: 15px;
189
+ }
190
+
191
+ /** Fixture */
192
+
193
+ #qunit-fixture {
194
+ position: absolute;
195
+ top: -10000px;
196
+ left: -10000px;
197
+ }