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
@@ -1,153 +0,0 @@
|
|
1
|
-
describe "Joosy.Modules.Container", ->
|
2
|
-
|
3
|
-
beforeEach ->
|
4
|
-
@$ground.seed()
|
5
|
-
container = @$ground.find('#application')
|
6
|
-
|
7
|
-
class @Container extends Joosy.Module
|
8
|
-
@include Joosy.Modules.Container
|
9
|
-
|
10
|
-
@mapElements
|
11
|
-
posts: '.post'
|
12
|
-
content:
|
13
|
-
post1: '#post1'
|
14
|
-
post2: '#post2'
|
15
|
-
footer: '.footer'
|
16
|
-
|
17
|
-
@mapEvents
|
18
|
-
'test': 'onContainerTest'
|
19
|
-
|
20
|
-
container: container
|
21
|
-
|
22
|
-
it "swaps container", ->
|
23
|
-
initial = (new @Container).container
|
24
|
-
parent = initial.parent()
|
25
|
-
event = sinon.spy()
|
26
|
-
|
27
|
-
# Binded events trigger
|
28
|
-
initial.bind 'test', event
|
29
|
-
initial.trigger 'test'
|
30
|
-
expect(event.callCount).toEqual 1
|
31
|
-
|
32
|
-
swapped = Joosy.Modules.Container.swapContainer initial, 'new content'
|
33
|
-
|
34
|
-
# Injects into DOM properly
|
35
|
-
expect(swapped.html()).toEqual 'new content'
|
36
|
-
expect(swapped.parent().get 0).toEqual parent.get 0
|
37
|
-
|
38
|
-
# Binded events disappear
|
39
|
-
swapped.trigger 'test'
|
40
|
-
expect(event.callCount).toEqual 1
|
41
|
-
|
42
|
-
describe "elements assigner", ->
|
43
|
-
|
44
|
-
beforeEach ->
|
45
|
-
@container = new @Container
|
46
|
-
@container.__assignElements()
|
47
|
-
|
48
|
-
it "declares", ->
|
49
|
-
class A extends @Container
|
50
|
-
@mapElements
|
51
|
-
first: 'first'
|
52
|
-
second: 'second'
|
53
|
-
|
54
|
-
class B extends A
|
55
|
-
@mapElements
|
56
|
-
first: 'overrided'
|
57
|
-
third: 'third'
|
58
|
-
|
59
|
-
expect((new B).__elements).toEqual Object.extended
|
60
|
-
posts: '.post'
|
61
|
-
content:
|
62
|
-
post1: '#post1'
|
63
|
-
post2: '#post2'
|
64
|
-
first: 'overrided'
|
65
|
-
second: 'second'
|
66
|
-
third: 'third'
|
67
|
-
footer: '.footer'
|
68
|
-
|
69
|
-
expect((new @Container).__elements).toEqual Object.extended
|
70
|
-
posts: '.post'
|
71
|
-
footer: '.footer'
|
72
|
-
content:
|
73
|
-
post1: '#post1'
|
74
|
-
post2: '#post2'
|
75
|
-
|
76
|
-
describe "selector resolvance", ->
|
77
|
-
|
78
|
-
it "works for plane selectors", ->
|
79
|
-
expect(@container.__extractSelector '$footer').toEqual '.footer'
|
80
|
-
|
81
|
-
it "works for deep selectors", ->
|
82
|
-
expect(@container.__extractSelector '$content.$post1').toEqual '#post1'
|
83
|
-
|
84
|
-
it "works for plane extended selectors", ->
|
85
|
-
expect(@container.__extractSelector '$footer tr').toEqual '.footer tr'
|
86
|
-
|
87
|
-
it "works for deep extended selectors", ->
|
88
|
-
expect(@container.__extractSelector '$footer $content.$post1').toEqual '.footer #post1'
|
89
|
-
|
90
|
-
it "assigns", ->
|
91
|
-
target = @container.$footer().get 0
|
92
|
-
expect(target).toBeTruthy()
|
93
|
-
expect(target).toBe $('.footer', @container.container).get 0
|
94
|
-
expect(target).toBe @container.$('.footer').get 0
|
95
|
-
|
96
|
-
it "assigns nesteds", ->
|
97
|
-
expect(@container.$content.$post1().get 0).toBe $('#post1').get 0
|
98
|
-
|
99
|
-
it "filters assignation", ->
|
100
|
-
target = @container.$posts('#post1').get 0
|
101
|
-
expect(target).toBeTruthy()
|
102
|
-
expect(target).toBe $('#post1', @container.container).get 0
|
103
|
-
|
104
|
-
it "respects container boundaries", ->
|
105
|
-
@$ground.prepend('<div class="footer" />') # out of container
|
106
|
-
|
107
|
-
target = @container.$footer().get 0
|
108
|
-
expect(target).toBeTruthy()
|
109
|
-
expect(target).toBe $('.footer', @container.container).get 0
|
110
|
-
expect(target).toBe @container.$('.footer').get 0
|
111
|
-
|
112
|
-
describe "events delegator", ->
|
113
|
-
|
114
|
-
it "declares", ->
|
115
|
-
class A extends @Container
|
116
|
-
@mapEvents
|
117
|
-
'test .post': 'callback2'
|
118
|
-
'custom' : 'method'
|
119
|
-
|
120
|
-
class B extends A
|
121
|
-
@mapEvents
|
122
|
-
'test $footer': 'onFooterTest'
|
123
|
-
'custom' : 'overrided'
|
124
|
-
|
125
|
-
expect((new B).__events).toEqual Object.extended
|
126
|
-
'test': 'onContainerTest'
|
127
|
-
'test .post': 'callback2'
|
128
|
-
'test $footer': 'onFooterTest'
|
129
|
-
'custom' : 'overrided'
|
130
|
-
|
131
|
-
expect((new @Container).__events).toEqual Object.extended
|
132
|
-
'test': 'onContainerTest'
|
133
|
-
|
134
|
-
it "delegates", ->
|
135
|
-
callbacks = 1.upto(3).map -> sinon.spy()
|
136
|
-
|
137
|
-
@Container.mapEvents
|
138
|
-
'test .post': callbacks[2]
|
139
|
-
'test $footer': 'onFooterTest'
|
140
|
-
@Container::onContainerTest = callbacks[0]
|
141
|
-
@Container::onFooterTest = callbacks[1]
|
142
|
-
|
143
|
-
container = new @Container
|
144
|
-
container.__assignElements()
|
145
|
-
container.__delegateEvents()
|
146
|
-
|
147
|
-
container.container.trigger 'test'
|
148
|
-
$('.footer', container.container).trigger 'test'
|
149
|
-
$('.post', container.container).trigger 'test'
|
150
|
-
|
151
|
-
expect(callbacks[0].callCount).toEqual 5
|
152
|
-
expect(callbacks[1].callCount).toEqual 1
|
153
|
-
expect(callbacks[2].callCount).toEqual 3
|
@@ -1,96 +0,0 @@
|
|
1
|
-
describe "Joosy.Modules.WidgetsManager", ->
|
2
|
-
|
3
|
-
beforeEach ->
|
4
|
-
class @Manager extends Joosy.Module
|
5
|
-
@include Joosy.Modules.Container
|
6
|
-
@include Joosy.Modules.WidgetsManager
|
7
|
-
|
8
|
-
class @Widget extends Joosy.Widget
|
9
|
-
constructor: (@argument) ->
|
10
|
-
|
11
|
-
@manager = new @Manager
|
12
|
-
|
13
|
-
describe "manager", ->
|
14
|
-
|
15
|
-
beforeEach ->
|
16
|
-
@widget = new @Widget
|
17
|
-
|
18
|
-
sinon.spy @widget, '__load'
|
19
|
-
sinon.spy @widget, '__unload'
|
20
|
-
|
21
|
-
it "registers widget", ->
|
22
|
-
result = @manager.registerWidget @$ground, @widget
|
23
|
-
expect(result instanceof @Widget).toBeTruthy()
|
24
|
-
expect(@manager.__activeWidgets).toEqual [result]
|
25
|
-
expect(@widget.__load.callCount).toEqual 1
|
26
|
-
|
27
|
-
it "unregisters widget", ->
|
28
|
-
@manager.registerWidget @$ground, @widget
|
29
|
-
|
30
|
-
expect(@manager.unregisterWidget @widget).toBeTruthy()
|
31
|
-
expect(@manager.__activeWidgets).toEqual []
|
32
|
-
expect(@widget.__unload.callCount).toEqual 1
|
33
|
-
|
34
|
-
it "unload all widgets properly", ->
|
35
|
-
3.times => @manager.registerWidget(@$ground, @widget)
|
36
|
-
@manager.__unloadWidgets()
|
37
|
-
expect(@widget.__unload.callCount).toEqual 3
|
38
|
-
|
39
|
-
describe 'declarator', ->
|
40
|
-
|
41
|
-
it "inherits widget declarations", ->
|
42
|
-
@Manager.mapWidgets
|
43
|
-
'test': 'widget'
|
44
|
-
|
45
|
-
class A extends @Manager
|
46
|
-
@mapWidgets
|
47
|
-
'selector': 'widget'
|
48
|
-
|
49
|
-
class B extends A
|
50
|
-
@mapWidgets
|
51
|
-
'widgets': 'widget'
|
52
|
-
'selector': 'overriden'
|
53
|
-
|
54
|
-
expect((new A).__widgets).toEqual Object.extended
|
55
|
-
'test': 'widget'
|
56
|
-
'selector': 'widget'
|
57
|
-
|
58
|
-
expect((new B).__widgets).toEqual Object.extended
|
59
|
-
'test': 'widget'
|
60
|
-
'widgets': 'widget'
|
61
|
-
'selector': 'overriden'
|
62
|
-
|
63
|
-
it "registers declared widgets", ->
|
64
|
-
@$ground.seed()
|
65
|
-
|
66
|
-
@Manager.mapElements
|
67
|
-
footer: '.footer'
|
68
|
-
|
69
|
-
@Manager.mapWidgets widgets =
|
70
|
-
'$container': Joosy.Widget
|
71
|
-
'$footer': Joosy.Widget
|
72
|
-
'.post': sinon.stub().returns new @Widget
|
73
|
-
|
74
|
-
@manager.container = $('#application')
|
75
|
-
@manager.__assignElements()
|
76
|
-
@manager.__setupWidgets()
|
77
|
-
|
78
|
-
expect(@manager.__activeWidgets.length).toEqual 5
|
79
|
-
expect(widgets['.post'].callCount).toEqual 3
|
80
|
-
expect(widgets['.post'].getCall(0).calledOn @manager).toBeTruthy()
|
81
|
-
|
82
|
-
it "bootstraps declared widgets properly", ->
|
83
|
-
@$ground.seed()
|
84
|
-
|
85
|
-
@Widget.view -> 'fluffy'
|
86
|
-
@Manager.mapWidgets
|
87
|
-
'#post1': @Widget
|
88
|
-
'#widget1': (i) => new @Widget i
|
89
|
-
|
90
|
-
@manager.container = $('#application')
|
91
|
-
@manager.__setupWidgets()
|
92
|
-
|
93
|
-
expect(@$ground.find('#post1').html()).toEqual 'fluffy'
|
94
|
-
expect(@$ground.find('#widget1').html()).toEqual 'fluffy'
|
95
|
-
expect(@manager.__activeWidgets[0].argument).toBeUndefined()
|
96
|
-
expect(@manager.__activeWidgets[1].argument).toEqual 0
|
@@ -1,59 +0,0 @@
|
|
1
|
-
#= require joosy/core/joosy
|
2
|
-
|
3
|
-
#
|
4
|
-
# Joosy Application container
|
5
|
-
#
|
6
|
-
# @mixin
|
7
|
-
#
|
8
|
-
Joosy.Application =
|
9
|
-
Pages: {}
|
10
|
-
Layouts: {}
|
11
|
-
Controls: {}
|
12
|
-
|
13
|
-
loading: true
|
14
|
-
identity: true
|
15
|
-
debounceForms: false
|
16
|
-
|
17
|
-
config:
|
18
|
-
debug: false
|
19
|
-
router:
|
20
|
-
html5: false
|
21
|
-
base: '/'
|
22
|
-
|
23
|
-
#
|
24
|
-
# Starts Joosy application by binding to element and bootstraping routes
|
25
|
-
#
|
26
|
-
# @param [String] name Name of app (the dir its located in)
|
27
|
-
# @param [String] selector jQuery-compatible selector of root application element
|
28
|
-
# @param [Object] options
|
29
|
-
#
|
30
|
-
initialize: (@name, @selector, options={}) ->
|
31
|
-
@mergeConfig(window.JoosyEnvironment) if window.JoosyEnvironment?
|
32
|
-
@mergeConfig(options)
|
33
|
-
|
34
|
-
@templater = new Joosy.Templaters.JST @name
|
35
|
-
|
36
|
-
Joosy.Router.__setupRoutes()
|
37
|
-
|
38
|
-
#
|
39
|
-
# Gets current application root node
|
40
|
-
#
|
41
|
-
content: ->
|
42
|
-
$(@selector)
|
43
|
-
|
44
|
-
#
|
45
|
-
# Switches to given page
|
46
|
-
#
|
47
|
-
# @param [Joosy.Page] page The class (not object) of page to load
|
48
|
-
# @param [Object] params Hash of page params
|
49
|
-
#
|
50
|
-
setCurrentPage: (page, params) ->
|
51
|
-
attempt = new page(params, @page)
|
52
|
-
@page = attempt unless attempt.halted
|
53
|
-
|
54
|
-
mergeConfig: (options) ->
|
55
|
-
for key, value of options
|
56
|
-
if Object.isObject @config[key]
|
57
|
-
Object.merge @config[key], value
|
58
|
-
else
|
59
|
-
@config[key] = value
|
@@ -1,52 +0,0 @@
|
|
1
|
-
#= require joosy/core/joosy
|
2
|
-
|
3
|
-
#
|
4
|
-
# Rendering and string representation helpers
|
5
|
-
#
|
6
|
-
Joosy.helpers 'Application', ->
|
7
|
-
|
8
|
-
#
|
9
|
-
# Generates HTML tag string
|
10
|
-
#
|
11
|
-
# @param [String] name Tag name
|
12
|
-
# @param [Object] options Tag attributes
|
13
|
-
# @param [String] content String content to inject
|
14
|
-
# @param [Function] content Function that will be evaluated and the result will be taken as a content
|
15
|
-
#
|
16
|
-
# Example
|
17
|
-
# != @tag 'div', {class: 'foo'}, =>
|
18
|
-
# != @tag 'hr'
|
19
|
-
#
|
20
|
-
@tag = (name, options={}, content='') ->
|
21
|
-
content = content() if Object.isFunction(content)
|
22
|
-
|
23
|
-
element = document.createElement name
|
24
|
-
temp = document.createElement 'div'
|
25
|
-
|
26
|
-
Object.each options, (name, value) -> element.setAttribute name, value
|
27
|
-
|
28
|
-
try
|
29
|
-
element.innerHTML = content
|
30
|
-
catch e
|
31
|
-
# setting innerHTML fails in the IE for elements, which cann't have children (INPUT, for ex.)
|
32
|
-
# suppress this error unless content looks valuable
|
33
|
-
throw e if content
|
34
|
-
|
35
|
-
temp.appendChild element
|
36
|
-
temp.innerHTML
|
37
|
-
|
38
|
-
#
|
39
|
-
# Wraps the inline block into given template
|
40
|
-
# Request template will receive the inline block as @yield parameter
|
41
|
-
#
|
42
|
-
# Example
|
43
|
-
# -# foo/baz template
|
44
|
-
# != @renderWrapped 'foo/bar', ->
|
45
|
-
# %b This string will be passed to 'foo/bar'
|
46
|
-
#
|
47
|
-
# -# foo/bar template
|
48
|
-
# %h1 I'm the wrapper here!
|
49
|
-
# != @yield
|
50
|
-
#
|
51
|
-
@renderWrapped = (template, lambda) ->
|
52
|
-
@render template, Joosy.Module.merge(this, yield: lambda())
|
@@ -1,174 +0,0 @@
|
|
1
|
-
#= require joosy/core/joosy
|
2
|
-
#= require joosy/core/modules/log
|
3
|
-
#= require joosy/core/modules/events
|
4
|
-
#= require joosy/core/modules/container
|
5
|
-
#= require joosy/core/modules/renderer
|
6
|
-
#= require joosy/core/modules/time_manager
|
7
|
-
#= require joosy/core/modules/widgets_manager
|
8
|
-
#= require joosy/core/modules/filters
|
9
|
-
|
10
|
-
#
|
11
|
-
# Base class for all of your Joosy Layouts.
|
12
|
-
# @see http://guides.joosy.ws/guides/layouts-pages-and-routing.html
|
13
|
-
#
|
14
|
-
# @example Sample application layout
|
15
|
-
# class @ApplicationLayout extends Joosy.Layout
|
16
|
-
# @view 'application'
|
17
|
-
#
|
18
|
-
# @include Joosy.Modules.Log
|
19
|
-
# @include Joosy.Modules.Events
|
20
|
-
# @include Joosy.Modules.Container
|
21
|
-
# @include Joosy.Modules.Renderer
|
22
|
-
# @include Joosy.Modules.TimeManager
|
23
|
-
# @include Joosy.Modules.WidgetsManager
|
24
|
-
# @include Joosy.Modules.Filters
|
25
|
-
#
|
26
|
-
class Joosy.Layout extends Joosy.Module
|
27
|
-
@include Joosy.Modules.Log
|
28
|
-
@include Joosy.Modules.Events
|
29
|
-
@include Joosy.Modules.Container
|
30
|
-
@include Joosy.Modules.Renderer
|
31
|
-
@include Joosy.Modules.TimeManager
|
32
|
-
@include Joosy.Modules.WidgetsManager
|
33
|
-
@include Joosy.Modules.Filters
|
34
|
-
|
35
|
-
@view 'default'
|
36
|
-
@helper 'page'
|
37
|
-
|
38
|
-
#
|
39
|
-
# Sets the method which will controll the painting preparation proccess.
|
40
|
-
#
|
41
|
-
# This method will be called right ater previous layout {Joosy.Layout.erase} and in parallel with
|
42
|
-
# layout data fetching so you can use it to initiate preloader.
|
43
|
-
#
|
44
|
-
# @note Given method will be called with `complete` function as parameter. As soon as your
|
45
|
-
# preparations are done you should call that function.
|
46
|
-
#
|
47
|
-
# @example Sample before painter
|
48
|
-
# @beforePaint (container, page, complete) ->
|
49
|
-
# if !@data # checks if parallel fetching finished
|
50
|
-
# $('preloader').slideDown -> complete()
|
51
|
-
#
|
52
|
-
#
|
53
|
-
@beforePaint: (callback) ->
|
54
|
-
@::__beforePaint = callback
|
55
|
-
|
56
|
-
#
|
57
|
-
# Sets the method which will controll the painting proccess.
|
58
|
-
#
|
59
|
-
# This method will be called after fetching, erasing and beforePaint is complete.
|
60
|
-
# It should be used to setup appearance effects of layout.
|
61
|
-
#
|
62
|
-
# @note Given method will be called with `complete` function as parameter. As soon as your
|
63
|
-
# preparations are done you should call that function.
|
64
|
-
#
|
65
|
-
# @example Sample painter
|
66
|
-
# @paint (container, page, complete) ->
|
67
|
-
# @container.fadeIn -> complete()
|
68
|
-
#
|
69
|
-
@paint: (callback) ->
|
70
|
-
@::__paint = callback
|
71
|
-
|
72
|
-
#
|
73
|
-
# Sets the method which will controll the erasing proccess.
|
74
|
-
#
|
75
|
-
# Use this method to setup hiding effect.
|
76
|
-
#
|
77
|
-
# @note Given method will be called with `complete` function as parameter. As soon as your
|
78
|
-
# preparations are done you should call that function.
|
79
|
-
#
|
80
|
-
# @note This method will be caled _before_ unload routines so in theory you can
|
81
|
-
# access layout data from that. Think twice if you are doing it right though.
|
82
|
-
#
|
83
|
-
# @example Sample eraser
|
84
|
-
# @erase (container, page, complete) ->
|
85
|
-
# @container.fadeOut -> complete()
|
86
|
-
#
|
87
|
-
@erase: (callback) ->
|
88
|
-
@::__erase = callback
|
89
|
-
|
90
|
-
#
|
91
|
-
# Sets the method which will controll the data fetching proccess.
|
92
|
-
#
|
93
|
-
# @note Given method will be called with `complete` function as parameter. As soon as your
|
94
|
-
# preparations are done you should call that function.
|
95
|
-
#
|
96
|
-
# @note You are strongly encouraged to NOT fetch anything with Layout!
|
97
|
-
# Use {Joosy.Page.fetch}
|
98
|
-
#
|
99
|
-
# @example Basic usage
|
100
|
-
# @fetch (complete) ->
|
101
|
-
# $.get '/rumbas', (@data) => complete()
|
102
|
-
#
|
103
|
-
@fetch: (callback) ->
|
104
|
-
@::__fetch = (complete) ->
|
105
|
-
@data = {}
|
106
|
-
callback.call this, =>
|
107
|
-
@dataFetched = true
|
108
|
-
complete()
|
109
|
-
|
110
|
-
#
|
111
|
-
# Prefetched page data.
|
112
|
-
#
|
113
|
-
data: false
|
114
|
-
dataFetched: false
|
115
|
-
|
116
|
-
#
|
117
|
-
# @param [Hash] params List of route params
|
118
|
-
#
|
119
|
-
constructor: (@params) ->
|
120
|
-
@uid = Joosy.uid()
|
121
|
-
|
122
|
-
#
|
123
|
-
# @see Joosy.Router.navigate
|
124
|
-
#
|
125
|
-
navigate: (args...) ->
|
126
|
-
Joosy.Router.navigate(args...)
|
127
|
-
|
128
|
-
#
|
129
|
-
# This is required by {Joosy.Modules.Renderer}
|
130
|
-
# Sets the base template dir to app_name/templates/layouts
|
131
|
-
#
|
132
|
-
__renderSection: ->
|
133
|
-
'layouts'
|
134
|
-
|
135
|
-
#
|
136
|
-
# Layout bootstrap proccess.
|
137
|
-
#
|
138
|
-
# * {Joosy.Modules.Container.__assignElements}
|
139
|
-
# * {Joosy.Modules.Container.__delegateEvents}
|
140
|
-
# * {Joosy.Modules.WidgetsManager.__setupWidgets}
|
141
|
-
#
|
142
|
-
__load: (@container) ->
|
143
|
-
@__assignElements()
|
144
|
-
@__delegateEvents()
|
145
|
-
@__setupWidgets()
|
146
|
-
@__runAfterLoads()
|
147
|
-
|
148
|
-
#
|
149
|
-
# Layout destruction proccess.
|
150
|
-
#
|
151
|
-
# * {Joosy.Modules.TimeManager.__clearTime}
|
152
|
-
# * {Joosy.Modules.WidgetsManager.__unloadWidgets}
|
153
|
-
# * {Joosy.Modules.Renderer.__removeMetamorphs}
|
154
|
-
#
|
155
|
-
__unload: ->
|
156
|
-
@__clearTime()
|
157
|
-
@__unloadWidgets()
|
158
|
-
@__removeMetamorphs()
|
159
|
-
@__runAfterUnloads()
|
160
|
-
|
161
|
-
#
|
162
|
-
# Helpers that outputs container for the page
|
163
|
-
#
|
164
|
-
page: (tag, options={}) ->
|
165
|
-
options.id = @uid
|
166
|
-
Joosy.Helpers.Application.tag tag, options
|
167
|
-
|
168
|
-
#
|
169
|
-
# Gets layout element.
|
170
|
-
#
|
171
|
-
# @return [jQuery]
|
172
|
-
#
|
173
|
-
content: ->
|
174
|
-
$("##{@uid}")
|