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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gruntfile.coffee +27 -7
- data/bin/joosy +1 -1
- data/bower.json +3 -2
- data/build/joosy/extensions/preloaders.js +189 -0
- data/build/joosy/extensions/resources-form.js +588 -0
- data/build/joosy/extensions/resources.js +673 -0
- data/build/joosy.js +2395 -0
- data/{src/joosy/generators → generators}/base.coffee +2 -2
- data/{src/joosy/generators → generators/command}/command.coffee +16 -3
- data/generators/command/help.coffee +38 -0
- data/{src/joosy/generators → generators}/layout.coffee +0 -0
- data/{src/joosy/generators → generators}/page.coffee +0 -0
- data/{src/joosy/generators → generators}/project/base.coffee +2 -4
- data/{src/joosy/generators → generators}/project/standalone.coffee +4 -3
- data/{src/joosy/generators → generators}/project.coffee +0 -0
- data/generators/templates/application/base/application.coffee +13 -0
- data/{templates → generators/templates}/application/base/helpers/application.coffee +0 -0
- data/{templates → generators/templates}/application/base/layouts/application.coffee +0 -0
- data/{templates → generators/templates}/application/base/pages/application.coffee +0 -0
- data/{templates → generators/templates}/application/base/pages/welcome/index.coffee +0 -0
- data/{templates → generators/templates}/application/base/routes.coffee +0 -0
- data/{templates → generators/templates}/application/base/templates/layouts/application.jst.hamlc +0 -0
- data/{templates → generators/templates}/application/base/templates/pages/welcome/index.jst.hamlc +0 -0
- data/{templates → generators/templates}/application/standalone/Gruntfile.coffee +1 -0
- data/{templates → generators/templates}/application/standalone/Procfile +0 -0
- data/{templates → generators/templates}/application/standalone/_gitignore +0 -0
- data/generators/templates/application/standalone/bower.json +17 -0
- data/{templates → generators/templates}/application/standalone/package.json +0 -0
- data/{templates → generators/templates}/application/standalone/source/haml/index.haml +0 -0
- data/{templates → generators/templates}/application/standalone/source/stylesheets/application.styl +0 -0
- data/{templates → generators/templates}/layout/basic.coffee +0 -0
- data/{templates → generators/templates}/layout/namespaced.coffee +0 -0
- data/{templates → generators/templates}/page/basic.coffee +0 -0
- data/{templates → generators/templates}/page/namespaced.coffee +0 -0
- data/{templates → generators/templates}/widget/basic.coffee +0 -0
- data/{templates → generators/templates}/widget/namespaced.coffee +0 -0
- data/{src/joosy/generators → generators}/widget.coffee +0 -0
- data/lib/joosy.rb +3 -3
- data/package.json +2 -3
- data/source/joosy/application.coffee +95 -0
- data/source/joosy/events/namespace.coffee +24 -0
- data/{src → source}/joosy/extensions/preloaders/caching.coffee +0 -0
- data/{src → source}/joosy/extensions/preloaders/index.coffee +0 -0
- data/{src → source}/joosy/extensions/preloaders/inline.coffee +0 -0
- data/{src → source}/joosy/extensions/resources/base.coffee +16 -8
- data/{src → source}/joosy/extensions/resources/collection.coffee +0 -0
- data/{src → source}/joosy/extensions/resources/index.coffee +0 -0
- data/{src → source}/joosy/extensions/resources/rest.coffee +0 -0
- data/{src → source}/joosy/extensions/resources/rest_collection.coffee +0 -0
- data/{src → source}/joosy/extensions/resources-form/form.coffee +18 -18
- data/{src → source}/joosy/extensions/resources-form/helpers/form.coffee +6 -6
- data/{src → source}/joosy/extensions/resources-form/index.coffee +0 -0
- data/source/joosy/helpers/routes.coffee +10 -0
- data/source/joosy/helpers/view.coffee +115 -0
- data/{src/joosy/core → source/joosy}/helpers/widgets.coffee +1 -1
- data/{src/joosy/core → source/joosy}/joosy.coffee +59 -19
- data/source/joosy/layout.coffee +73 -0
- data/{src/joosy/core → source/joosy}/module.coffee +7 -2
- data/{src/joosy/core/modules/container.coffee → source/joosy/modules/dom.coffee} +24 -17
- data/source/joosy/modules/events.coffee +156 -0
- data/source/joosy/modules/filters.coffee +67 -0
- data/{src/joosy/core → source/joosy}/modules/log.coffee +7 -3
- data/source/joosy/modules/page/scrolling.coffee +51 -0
- data/source/joosy/modules/page/title.coffee +18 -0
- data/{src/joosy/core → source/joosy}/modules/renderer.coffee +12 -13
- data/{src/joosy/core → source/joosy}/modules/time_manager.coffee +5 -1
- data/{src/joosy/core → source/joosy}/modules/widgets_manager.coffee +9 -5
- data/source/joosy/page.coffee +68 -0
- data/{src/joosy/core → source/joosy}/resources/watcher.coffee +5 -1
- data/source/joosy/router.coffee +305 -0
- data/{src/joosy/core → source/joosy}/templaters/jst.coffee +10 -7
- data/source/joosy/widget.coffee +385 -0
- data/source/joosy.coffee +1 -0
- data/{src/vendor → source}/metamorph.coffee +0 -0
- data/spec/helpers/matchers.coffee +8 -1
- data/spec/joosy/core/application_spec.coffee +121 -20
- data/spec/joosy/core/helpers/view_spec.coffee +3 -3
- data/spec/joosy/core/helpers/widgets_spec.coffee +3 -6
- data/spec/joosy/core/joosy_spec.coffee +0 -5
- data/spec/joosy/core/layout_spec.coffee +2 -28
- data/spec/joosy/core/modules/dom_spec.coffee +133 -0
- data/spec/joosy/core/modules/events_spec.coffee +16 -9
- data/spec/joosy/core/modules/filters_spec.coffee +232 -89
- data/spec/joosy/core/modules/log_spec.coffee +2 -2
- data/spec/joosy/core/modules/renderer_spec.coffee +8 -4
- data/spec/joosy/core/page_spec.coffee +2 -201
- data/spec/joosy/core/router_spec.coffee +295 -233
- data/spec/joosy/core/templaters/jst_spec.coffee +1 -1
- data/spec/joosy/core/widget_spec.coffee +373 -34
- data/spec/joosy/environments/amd_spec.coffee +38 -0
- data/spec/joosy/environments/global_spec.coffee +21 -0
- data/spec/joosy/extensions/form/form_spec.coffee +18 -18
- data/spec/joosy/extensions/form/helpers/forms_spec.coffee +1 -1
- data/spec/joosy/extensions/resources/base_spec.coffee +23 -11
- data/tasks/joosy.coffee +6 -9
- metadata +75 -69
- data/lib/extensions/preloaders.js +0 -193
- data/lib/extensions/resources-form.js +0 -592
- data/lib/extensions/resources.js +0 -675
- data/lib/joosy.js +0 -2199
- data/spec/joosy/core/modules/container_spec.coffee +0 -153
- data/spec/joosy/core/modules/widget_manager_spec.coffee +0 -96
- data/src/joosy/core/application.coffee +0 -59
- data/src/joosy/core/helpers/view.coffee +0 -52
- data/src/joosy/core/layout.coffee +0 -174
- data/src/joosy/core/modules/events.coffee +0 -188
- data/src/joosy/core/modules/filters.coffee +0 -42
- data/src/joosy/core/page.coffee +0 -383
- data/src/joosy/core/router.coffee +0 -313
- data/src/joosy/core/widget.coffee +0 -88
- data/src/joosy.coffee +0 -1
- data/templates/application/base/application.coffee +0 -9
- 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()
|