joosy 1.2.0.alpha.41 → 1.2.0.alpha.51

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gruntfile.coffee +27 -7
  4. data/bin/joosy +1 -1
  5. data/bower.json +3 -2
  6. data/build/joosy/extensions/preloaders.js +189 -0
  7. data/build/joosy/extensions/resources-form.js +588 -0
  8. data/build/joosy/extensions/resources.js +673 -0
  9. data/build/joosy.js +2395 -0
  10. data/{src/joosy/generators → generators}/base.coffee +2 -2
  11. data/{src/joosy/generators → generators/command}/command.coffee +16 -3
  12. data/generators/command/help.coffee +38 -0
  13. data/{src/joosy/generators → generators}/layout.coffee +0 -0
  14. data/{src/joosy/generators → generators}/page.coffee +0 -0
  15. data/{src/joosy/generators → generators}/project/base.coffee +2 -4
  16. data/{src/joosy/generators → generators}/project/standalone.coffee +4 -3
  17. data/{src/joosy/generators → generators}/project.coffee +0 -0
  18. data/generators/templates/application/base/application.coffee +13 -0
  19. data/{templates → generators/templates}/application/base/helpers/application.coffee +0 -0
  20. data/{templates → generators/templates}/application/base/layouts/application.coffee +0 -0
  21. data/{templates → generators/templates}/application/base/pages/application.coffee +0 -0
  22. data/{templates → generators/templates}/application/base/pages/welcome/index.coffee +0 -0
  23. data/{templates → generators/templates}/application/base/routes.coffee +0 -0
  24. data/{templates → generators/templates}/application/base/templates/layouts/application.jst.hamlc +0 -0
  25. data/{templates → generators/templates}/application/base/templates/pages/welcome/index.jst.hamlc +0 -0
  26. data/{templates → generators/templates}/application/standalone/Gruntfile.coffee +1 -0
  27. data/{templates → generators/templates}/application/standalone/Procfile +0 -0
  28. data/{templates → generators/templates}/application/standalone/_gitignore +0 -0
  29. data/generators/templates/application/standalone/bower.json +17 -0
  30. data/{templates → generators/templates}/application/standalone/package.json +0 -0
  31. data/{templates → generators/templates}/application/standalone/source/haml/index.haml +0 -0
  32. data/{templates → generators/templates}/application/standalone/source/stylesheets/application.styl +0 -0
  33. data/{templates → generators/templates}/layout/basic.coffee +0 -0
  34. data/{templates → generators/templates}/layout/namespaced.coffee +0 -0
  35. data/{templates → generators/templates}/page/basic.coffee +0 -0
  36. data/{templates → generators/templates}/page/namespaced.coffee +0 -0
  37. data/{templates → generators/templates}/widget/basic.coffee +0 -0
  38. data/{templates → generators/templates}/widget/namespaced.coffee +0 -0
  39. data/{src/joosy/generators → generators}/widget.coffee +0 -0
  40. data/lib/joosy.rb +3 -3
  41. data/package.json +2 -3
  42. data/source/joosy/application.coffee +95 -0
  43. data/source/joosy/events/namespace.coffee +24 -0
  44. data/{src → source}/joosy/extensions/preloaders/caching.coffee +0 -0
  45. data/{src → source}/joosy/extensions/preloaders/index.coffee +0 -0
  46. data/{src → source}/joosy/extensions/preloaders/inline.coffee +0 -0
  47. data/{src → source}/joosy/extensions/resources/base.coffee +16 -8
  48. data/{src → source}/joosy/extensions/resources/collection.coffee +0 -0
  49. data/{src → source}/joosy/extensions/resources/index.coffee +0 -0
  50. data/{src → source}/joosy/extensions/resources/rest.coffee +0 -0
  51. data/{src → source}/joosy/extensions/resources/rest_collection.coffee +0 -0
  52. data/{src → source}/joosy/extensions/resources-form/form.coffee +18 -18
  53. data/{src → source}/joosy/extensions/resources-form/helpers/form.coffee +6 -6
  54. data/{src → source}/joosy/extensions/resources-form/index.coffee +0 -0
  55. data/source/joosy/helpers/routes.coffee +10 -0
  56. data/source/joosy/helpers/view.coffee +115 -0
  57. data/{src/joosy/core → source/joosy}/helpers/widgets.coffee +1 -1
  58. data/{src/joosy/core → source/joosy}/joosy.coffee +59 -19
  59. data/source/joosy/layout.coffee +73 -0
  60. data/{src/joosy/core → source/joosy}/module.coffee +7 -2
  61. data/{src/joosy/core/modules/container.coffee → source/joosy/modules/dom.coffee} +24 -17
  62. data/source/joosy/modules/events.coffee +156 -0
  63. data/source/joosy/modules/filters.coffee +67 -0
  64. data/{src/joosy/core → source/joosy}/modules/log.coffee +7 -3
  65. data/source/joosy/modules/page/scrolling.coffee +51 -0
  66. data/source/joosy/modules/page/title.coffee +18 -0
  67. data/{src/joosy/core → source/joosy}/modules/renderer.coffee +12 -13
  68. data/{src/joosy/core → source/joosy}/modules/time_manager.coffee +5 -1
  69. data/{src/joosy/core → source/joosy}/modules/widgets_manager.coffee +9 -5
  70. data/source/joosy/page.coffee +68 -0
  71. data/{src/joosy/core → source/joosy}/resources/watcher.coffee +5 -1
  72. data/source/joosy/router.coffee +305 -0
  73. data/{src/joosy/core → source/joosy}/templaters/jst.coffee +10 -7
  74. data/source/joosy/widget.coffee +385 -0
  75. data/source/joosy.coffee +1 -0
  76. data/{src/vendor → source}/metamorph.coffee +0 -0
  77. data/spec/helpers/matchers.coffee +8 -1
  78. data/spec/joosy/core/application_spec.coffee +121 -20
  79. data/spec/joosy/core/helpers/view_spec.coffee +3 -3
  80. data/spec/joosy/core/helpers/widgets_spec.coffee +3 -6
  81. data/spec/joosy/core/joosy_spec.coffee +0 -5
  82. data/spec/joosy/core/layout_spec.coffee +2 -28
  83. data/spec/joosy/core/modules/dom_spec.coffee +133 -0
  84. data/spec/joosy/core/modules/events_spec.coffee +16 -9
  85. data/spec/joosy/core/modules/filters_spec.coffee +232 -89
  86. data/spec/joosy/core/modules/log_spec.coffee +2 -2
  87. data/spec/joosy/core/modules/renderer_spec.coffee +8 -4
  88. data/spec/joosy/core/page_spec.coffee +2 -201
  89. data/spec/joosy/core/router_spec.coffee +295 -233
  90. data/spec/joosy/core/templaters/jst_spec.coffee +1 -1
  91. data/spec/joosy/core/widget_spec.coffee +373 -34
  92. data/spec/joosy/environments/amd_spec.coffee +38 -0
  93. data/spec/joosy/environments/global_spec.coffee +21 -0
  94. data/spec/joosy/extensions/form/form_spec.coffee +18 -18
  95. data/spec/joosy/extensions/form/helpers/forms_spec.coffee +1 -1
  96. data/spec/joosy/extensions/resources/base_spec.coffee +23 -11
  97. data/tasks/joosy.coffee +6 -9
  98. metadata +75 -69
  99. data/lib/extensions/preloaders.js +0 -193
  100. data/lib/extensions/resources-form.js +0 -592
  101. data/lib/extensions/resources.js +0 -675
  102. data/lib/joosy.js +0 -2199
  103. data/spec/joosy/core/modules/container_spec.coffee +0 -153
  104. data/spec/joosy/core/modules/widget_manager_spec.coffee +0 -96
  105. data/src/joosy/core/application.coffee +0 -59
  106. data/src/joosy/core/helpers/view.coffee +0 -52
  107. data/src/joosy/core/layout.coffee +0 -174
  108. data/src/joosy/core/modules/events.coffee +0 -188
  109. data/src/joosy/core/modules/filters.coffee +0 -42
  110. data/src/joosy/core/page.coffee +0 -383
  111. data/src/joosy/core/router.coffee +0 -313
  112. data/src/joosy/core/widget.coffee +0 -88
  113. data/src/joosy.coffee +0 -1
  114. data/templates/application/base/application.coffee +0 -9
  115. data/templates/application/standalone/bower.json +0 -7
@@ -9,18 +9,11 @@ describe "Joosy.Page", ->
9
9
  @layout Layout
10
10
 
11
11
  sinon.stub @Page.prototype, '__bootstrap'
12
- sinon.stub @Page.prototype, '__bootstrapLayout'
13
12
 
14
13
  afterEach ->
15
14
  @Page::__bootstrap.restore()
16
- @Page::__bootstrapLayout.restore()
17
15
 
18
16
  it "has appropriate accessors", ->
19
- callbackNames = ['beforePaint', 'paint', 'afterPaint', 'erase']
20
- callbackNames.each (callbackName) =>
21
- @Page[callbackName] 'callback'
22
- expect(@Page::['__' + callbackName]).toEqual 'callback'
23
-
24
17
  @Page.scroll '#here'
25
18
  expect(@Page::__scrollElement).toEqual '#here'
26
19
  expect(@Page::__scrollSpeed).toEqual 500
@@ -36,7 +29,7 @@ describe "Joosy.Page", ->
36
29
 
37
30
  it "integrates with Router", ->
38
31
  target = sinon.stub Joosy.Router, 'navigate'
39
- (new @Page).navigate 'there'
32
+ (new @Page $('#application')).navigate 'there'
40
33
  expect(target.callCount).toEqual 1
41
34
  expect(target.alwaysCalledWithExactly 'there').toBeTruthy()
42
35
  Joosy.Router.navigate.restore()
@@ -45,198 +38,6 @@ describe "Joosy.Page", ->
45
38
  sinon.stub @Page.prototype, '__runBeforeLoads'
46
39
  @Page::__runBeforeLoads.returns(false)
47
40
 
48
- new @Page
41
+ new @Page $('#application')
49
42
 
50
43
  expect(@Page::__bootstrap.callCount).toEqual 0
51
- expect(@Page::__bootstrapLayout.callCount).toEqual 0
52
-
53
- describe "layout switcher", ->
54
-
55
- beforeEach ->
56
- @page = new @Page
57
- @page.layout = new @Layout
58
-
59
- it "does not render when previous layout is the same", ->
60
- new @Page {}, @page
61
-
62
- expect(@Page::__bootstrap.callCount).toEqual 1
63
- expect(@Page::__bootstrapLayout.callCount).toEqual 1
64
-
65
- it "renders when previous layout is another class", ->
66
- class Layout extends Joosy.Layout
67
- class Page extends Joosy.Page
68
- @layout Layout
69
-
70
- sinon.stub Page.prototype, '__bootstrap'
71
- sinon.stub Page.prototype, '__bootstrapLayout'
72
-
73
- new Page {}, @page
74
-
75
- expect(@Page::__bootstrap.callCount).toEqual 0
76
- expect(@Page::__bootstrapLayout.callCount).toEqual 1
77
- expect(Page::__bootstrap.callCount).toEqual 0
78
- expect(Page::__bootstrapLayout.callCount).toEqual 1
79
-
80
- it "loads", ->
81
- page = new @Page
82
-
83
- spies = []
84
- spies.push sinon.spy(page, '__assignElements')
85
- spies.push sinon.spy(page, '__delegateEvents')
86
- spies.push sinon.spy(page, '__setupWidgets')
87
- spies.push sinon.spy(page, '__runAfterLoads')
88
- page.__load()
89
- expect(spies).toBeSequenced()
90
-
91
- it "unloads", ->
92
- page = new @Page
93
-
94
- spies = []
95
- spies.push sinon.spy(page, '__clearTime')
96
- spies.push sinon.spy(page, '__unloadWidgets')
97
- spies.push sinon.spy(page, '__removeMetamorphs')
98
- spies.push sinon.spy(page, '__runAfterUnloads')
99
- page.__unload()
100
- expect(spies).toBeSequenced()
101
-
102
- describe "rendering", ->
103
-
104
- beforeEach ->
105
- # Layouts inject themselves into `Joosy.Application.content`
106
- # so let's make them inject where we want
107
- sinon.stub Joosy.Application, 'content'
108
- Joosy.Application.content.returns @$ground
109
-
110
- # We test every module separately so there's no need to run all those
111
- sinon.stub Joosy.Page.prototype, '__load'
112
- sinon.stub Joosy.Page.prototype, '__unload'
113
- sinon.stub Joosy.Layout.prototype, '__load'
114
- sinon.stub Joosy.Layout.prototype, '__unload'
115
-
116
- afterEach ->
117
- Joosy.Application.content.restore()
118
- Joosy.Page::__load.restore()
119
- Joosy.Page::__unload.restore()
120
- Joosy.Layout::__load.restore()
121
- Joosy.Layout::__unload.restore()
122
-
123
- it "renders", ->
124
- class Layout extends Joosy.Layout
125
- @view (locals) -> locals.page 'div', class: 'layout'
126
-
127
- class Page extends Joosy.Page
128
- @layout Layout
129
- @view (locals) -> 'page'
130
-
131
- page = new Page
132
- expect(@$ground.html()).toMatch /<div class\=\"layout\" id=\"__joosy\d+\">page<\/div>/
133
-
134
- it "changes page", ->
135
- class Layout extends Joosy.Layout
136
- @view (locals) -> locals.page 'div'
137
-
138
- class PageA extends Joosy.Page
139
- @layout Layout
140
- @view (locals) -> 'page a'
141
-
142
- class PageB extends Joosy.Page
143
- @layout Layout
144
- @view (locals) -> 'page b'
145
-
146
- page = new PageA
147
- expect(@$ground.html()).toMatch /<div id=\"__joosy\d+\">page a<\/div>/
148
-
149
- page = new PageB {}, page
150
- expect(@$ground.html()).toMatch /<div id=\"__joosy\d+\">page b<\/div>/
151
-
152
- it "changes layout", ->
153
- class LayoutA extends Joosy.Layout
154
- @view (locals) -> locals.page 'div'
155
-
156
- class PageA extends Joosy.Page
157
- @layout LayoutA
158
- @view (locals) -> ''
159
-
160
- class LayoutB extends Joosy.Layout
161
- @view (locals) -> locals.page 'div'
162
-
163
- class PageB extends Joosy.Page
164
- @layout LayoutB
165
- @view (locals) -> ''
166
-
167
- page = new PageA
168
- html = @$ground.html()
169
- expect(html).toMatch /<div id=\"__joosy\d+\"><\/div>/
170
-
171
- page = new PageB {}, page
172
- expect(@$ground.html()).toMatch /<div id=\"__joosy\d+\"><\/div>/
173
- expect(@$ground.html()).not.toEqual html
174
-
175
- it "proxies @params to layout", ->
176
- class Layout extends Joosy.Layout
177
- @view (locals) -> locals.page 'div', class: 'layout'
178
-
179
- constructor: (@params) ->
180
- expect(@params).toEqual foo: 'bar'
181
- super
182
-
183
- class Page extends Joosy.Page
184
- @layout Layout
185
- @view (locals) -> 'page'
186
-
187
- page = new Page foo: 'bar'
188
-
189
- it "passes @data to @view", ->
190
- class Layout extends Joosy.Layout
191
- @fetch (complete) ->
192
- expect(@data).toEqual {}
193
- @data.foo = 'bar'
194
- complete()
195
-
196
- @view (locals) ->
197
- expect(locals.foo).toEqual 'bar'
198
-
199
- class Page extends Joosy.Page
200
- @layout Layout
201
-
202
- @fetch (complete) ->
203
- expect(@data).toEqual {}
204
- @data.foo = 'bar'
205
- complete()
206
-
207
- @view (locals) ->
208
- expect(locals.foo).toEqual 'bar'
209
-
210
- page = new Page
211
-
212
- it "hooks", ->
213
- spies = []
214
- 11.times -> spies.push sinon.spy()
215
-
216
- class Layout extends Joosy.Layout
217
- @beforePaint (container, page, complete) -> spies[0](); complete()
218
- @fetch (complete) -> spies[1](); complete()
219
- @paint (container, page, complete) -> spies[3](); complete()
220
-
221
- @view spies[4]
222
-
223
- class PageA extends Joosy.Page
224
- @layout Layout
225
-
226
- @fetch (complete) -> spies[2](); complete()
227
- @erase (container, complete) -> spies[6](); complete()
228
- @view spies[5]
229
-
230
- class PageB extends Joosy.Page
231
- @layout Layout
232
-
233
- @beforePaint (container, complete) -> spies[7](); complete()
234
- @fetch (complete) -> spies[8](); complete()
235
- @paint (container, complete) -> spies[9](); complete()
236
-
237
- @view spies[10]
238
-
239
- page = new PageA
240
- page = new PageB {}, page
241
-
242
- expect(spies).toBeSequenced()