ende 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/component.json +4 -5
- data/lib/assets/javascripts/aura/extensions/loader.js.coffee +15 -11
- data/lib/assets/javascripts/aura/extensions/mask.js.coffee +13 -77
- data/lib/assets/javascripts/aura/extensions/models.js.coffee.erb +1 -1
- data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +1 -0
- data/lib/assets/javascripts/aura/extensions/routes.js.coffee +14 -9
- data/lib/assets/javascripts/aura/extensions/states.js.coffee +27 -22
- data/lib/assets/javascripts/config/initializers/jquery.js.coffee +7 -7
- data/lib/assets/javascripts/config/initializers/requirejs.js.coffee +1 -0
- data/lib/assets/javascripts/config/{initializers/load_components.js.coffee → load_components.js.coffee} +7 -4
- data/lib/assets/javascripts/ende.js.coffee +1 -0
- data/lib/assets/javascripts/widgets/viewer/main.js.coffee +80 -23
- data/lib/assets/javascripts/widgets/viewer/plugins/scopable.js.coffee +87 -15
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/build.css +111 -0
- data/vendor/assets/components/build.js +28280 -0
- data/vendor/assets/components/ende_build.js +4955 -6751
- data/vendor/components/indefinido-observable/component.json +1 -2
- data/vendor/components/indefinido-observable/lib/observable.js +28 -6
- data/vendor/components/mikeric-rivets/component.json +2 -2
- data/vendor/components/mikeric-rivets/dist/rivets.js +632 -873
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 508121894c529c825b8be23734809551052843b0
|
4
|
+
data.tar.gz: c1bb6a5676fcff34bb0c33b60f869bf96c8d4989
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1ace745145b3787b7b74fbc1ea6d022137e26c98d4d3ac9e0bec815fca1d0144a808f00eb60ee5a057e2a4b2fcbb0d1eb20dd11624cec82886bd022058edb6a
|
7
|
+
data.tar.gz: a1e37960784210d21d53baef5aa9dc4a8065ec2d33ae6e6620ffe5a91643315b0e25fbbeb863d7cd12a50fbb3560f2a626cd290783dc8bcbe080e144529158a9
|
data/component.json
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "ened",
|
3
3
|
"repo": "indefinido/ened",
|
4
|
-
"description": "Core web application
|
5
|
-
"version": "0.0
|
4
|
+
"description": "Core web application functionacility",
|
5
|
+
"version": "0.1.0",
|
6
6
|
"keywords": [],
|
7
7
|
"dependencies": {
|
8
|
-
"mikeric/rivets": "
|
9
|
-
"KapIT/observe-utils": "*",
|
8
|
+
"mikeric/rivets": "v0.5.12",
|
10
9
|
"segmentio/extend": "*",
|
11
10
|
"pluma/assimilate": "*",
|
12
11
|
"paulmillr/es6-shim": "*",
|
@@ -32,4 +31,4 @@
|
|
32
31
|
"vendor/assets/javascripts"
|
33
32
|
],
|
34
33
|
"license": "MIT"
|
35
|
-
}
|
34
|
+
}
|
@@ -2,15 +2,10 @@ define 'aura/extensions/loader', ->
|
|
2
2
|
|
3
3
|
'use strict';
|
4
4
|
|
5
|
-
|
6
|
-
Spinner = require 'seminovos/vendor/assets/javascripts/spin/spin'
|
7
|
-
catch e
|
8
|
-
Spinner = require 'modacad/vendor/assets/javascripts/spin/spin'
|
9
|
-
|
5
|
+
Spinner = null
|
10
6
|
|
11
7
|
(application) ->
|
12
|
-
core = application
|
13
|
-
mediator = core.mediator
|
8
|
+
{core} = application
|
14
9
|
|
15
10
|
loader =
|
16
11
|
|
@@ -41,8 +36,17 @@ define 'aura/extensions/loader', ->
|
|
41
36
|
new Spinner(core.util.extend {}, @options, options).spin target[0]
|
42
37
|
|
43
38
|
name: 'loader'
|
39
|
+
version: '0.1.0'
|
44
40
|
initialize: (application) ->
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
{sandbox} = application
|
42
|
+
|
43
|
+
# TODO add a default spinner on ende, and add application load
|
44
|
+
# paths
|
45
|
+
try
|
46
|
+
Spinner = require 'seminovos/vendor/assets/javascripts/spin/spin'
|
47
|
+
catch e
|
48
|
+
Spinner = require 'modacad/vendor/assets/javascripts/spin/spin'
|
49
|
+
|
50
|
+
# Extend application
|
51
|
+
sandbox.ui = core.util.extend sandbox.ui, loader: -> loader.create arguments...
|
52
|
+
core.ui = core.util.extend core.ui , loader: -> loader.create arguments...
|
@@ -20,25 +20,25 @@ $.extend $.inputmask.defaults.aliases,
|
|
20
20
|
digits : 2
|
21
21
|
allowMinus : false
|
22
22
|
allowPlus : false
|
23
|
-
|
23
|
+
|
24
24
|
plate:
|
25
25
|
mask : 'AAA-9999'
|
26
|
-
|
26
|
+
|
27
27
|
meters:
|
28
28
|
alias : 'integer'
|
29
29
|
allowMinus : false
|
30
30
|
allowPlus : false
|
31
31
|
integerDigits : 6
|
32
|
-
|
32
|
+
|
33
33
|
cpf:
|
34
34
|
mask : '999.999.999-99'
|
35
|
-
|
35
|
+
|
36
36
|
cnpj:
|
37
37
|
mask : '99.999.999/9999-99'
|
38
|
-
|
38
|
+
|
39
39
|
phone:
|
40
40
|
mask : '(99) 9999[9]-9999'
|
41
|
-
|
41
|
+
|
42
42
|
|
43
43
|
|
44
44
|
define 'aura/extensions/mask', (mask) ->
|
@@ -47,79 +47,15 @@ define 'aura/extensions/mask', (mask) ->
|
|
47
47
|
|
48
48
|
|
49
49
|
(application) ->
|
50
|
-
|
51
|
-
|
50
|
+
|
51
|
+
|
52
52
|
mask = (selector, mask, options) ->
|
53
53
|
$(selector).inputmask mask, options
|
54
|
-
|
55
54
|
|
56
|
-
|
55
|
+
|
56
|
+
version: '0.1.0'
|
57
57
|
|
58
58
|
initialize: (application) ->
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
#
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
# # TODO Remove .call null
|
74
|
-
# # TODO Remove .call null
|
75
|
-
# loader.require.call null, 'modernizr'
|
76
|
-
# loader.require.call null, 'ened/vendor/assets/javascripts/lennon/lennon.js'
|
77
|
-
# query = loader.require.call null, 'querystring'
|
78
|
-
# router = null
|
79
|
-
#
|
80
|
-
# # TODO rename to router stationg
|
81
|
-
# (application) ->
|
82
|
-
# core = application.core
|
83
|
-
# mediator = core.mediator
|
84
|
-
#
|
85
|
-
# # TODO unify router api
|
86
|
-
# router = new Lennon
|
87
|
-
# # TODO implement logger api for lennon or change lennon library
|
88
|
-
# # logger: application.logger
|
89
|
-
# publishEvent: (name, params) ->
|
90
|
-
#
|
91
|
-
# current_route = window.location.href
|
92
|
-
# if router.last_route != current_route
|
93
|
-
# mediator.emit 'route.changed'
|
94
|
-
# router.last_route = current_route
|
95
|
-
#
|
96
|
-
# # TODO method parsing (get, delete, put, post)
|
97
|
-
# mediator.emit name, params
|
98
|
-
#
|
99
|
-
# router.location = (href, process = true) ->
|
100
|
-
# if Modernizr.history
|
101
|
-
# window.history.pushState null, null, href
|
102
|
-
# else
|
103
|
-
# # TODO parse href and extract path!
|
104
|
-
# window.location.hash = href
|
105
|
-
#
|
106
|
-
# process and router.process()
|
107
|
-
#
|
108
|
-
#
|
109
|
-
# application.core.router = router
|
110
|
-
#
|
111
|
-
# location = Object.create null,
|
112
|
-
# # TODO cache query parsing
|
113
|
-
# query:
|
114
|
-
# get: -> query.parse window.location.search.substring(1)
|
115
|
-
#
|
116
|
-
# toString: -> window.location
|
117
|
-
#
|
118
|
-
# version: '0.2.1'
|
119
|
-
#
|
120
|
-
# initialize: (application) ->
|
121
|
-
# application.sandbox.ui.mask = mask
|
122
|
-
#
|
123
|
-
# afterAppStart: (application) ->
|
124
|
-
# router.process()
|
125
|
-
#
|
59
|
+
{core, sandbox} = application
|
60
|
+
|
61
|
+
sandbox.ui = sandbox.util.extend sandbox.ui, mask: mask
|
@@ -61,7 +61,7 @@ define 'aura/extensions/models', <%= models_list.to_json %>, (models...) ->
|
|
61
61
|
core.resource = core.model = sandbox.resource = sandbox.model = (name) ->
|
62
62
|
# TODO use a Map internally in indemma
|
63
63
|
model = indemma.model[name]
|
64
|
-
throw new
|
64
|
+
throw new TypeError "resources: Resource was not defined: #{name}" unless model?
|
65
65
|
model
|
66
66
|
|
67
67
|
# TODO rename core.models and core.domain, to core.resources, completely
|
@@ -16,6 +16,7 @@ define 'aura/extensions/rivets', ['extensions/rivets/formatters'], (formatters)-
|
|
16
16
|
|
17
17
|
rivets.configure observable_configuration
|
18
18
|
rivets.configure
|
19
|
+
prefix: ''
|
19
20
|
templateDelimiters: ['{{', '}}']
|
20
21
|
|
21
22
|
# Custom rivets view because we don't want to prefix attributes
|
@@ -5,6 +5,7 @@ define 'aura/extensions/routes', (routes) ->
|
|
5
5
|
# TODO Remove .call null
|
6
6
|
# TODO Remove .call null
|
7
7
|
loader.require.call null, 'modernizr'
|
8
|
+
# TODO rename from ened to ende
|
8
9
|
loader.require.call null, 'ened/vendor/assets/javascripts/lennon/lennon.js'
|
9
10
|
query = loader.require.call null, 'querystring'
|
10
11
|
router = null
|
@@ -28,17 +29,21 @@ define 'aura/extensions/routes', (routes) ->
|
|
28
29
|
# TODO method parsing (get, delete, put, post)
|
29
30
|
mediator.emit name, params
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
lennon_extensions =
|
33
|
+
location: (href, process = true) ->
|
34
|
+
if Modernizr.history
|
35
|
+
window.history.pushState null, null, href
|
36
|
+
else
|
37
|
+
# TODO parse href and extract path!
|
38
|
+
window.location.hash = href
|
37
39
|
|
38
|
-
|
40
|
+
process and router.process()
|
39
41
|
|
42
|
+
define: ->
|
43
|
+
return false
|
40
44
|
|
41
|
-
|
45
|
+
|
46
|
+
application.core.router = core.util.extend router, lennon_extensions
|
42
47
|
|
43
48
|
location = Object.create null,
|
44
49
|
# TODO cache query parsing
|
@@ -53,5 +58,5 @@ define 'aura/extensions/routes', (routes) ->
|
|
53
58
|
application.sandbox.location = location
|
54
59
|
|
55
60
|
afterAppStart: (application) ->
|
56
|
-
router.process()
|
61
|
+
# router.process()
|
57
62
|
|
@@ -35,48 +35,53 @@ define 'aura/extensions/states', ['application/states'], (states) ->
|
|
35
35
|
unormalized_widget_options = states[transition.to]
|
36
36
|
|
37
37
|
# TODO cache rendered widgets!
|
38
|
-
|
39
38
|
if unormalized_widget_options
|
40
|
-
|
41
|
-
|
42
|
-
for name, options of unormalized_widget_options
|
43
|
-
widget_name = options.name || name
|
44
|
-
options.resource ||= name unless name == widget_name
|
45
|
-
|
46
|
-
# To allow user controlling the application change the
|
47
|
-
# widget configuration at runtime, we check the transition
|
48
|
-
# for widget options
|
49
|
-
widgets.push
|
50
|
-
name: widget_name
|
51
|
-
options: core.util.extend transition[widget_name], options
|
52
|
-
|
53
|
-
# TODO document why we delete this?
|
54
|
-
delete options.name
|
39
|
+
widgets_options = @normalize_widget_options unormalized_widget_options, transition
|
55
40
|
|
56
41
|
# TODO update aura and use native start method
|
57
|
-
#
|
58
|
-
|
59
|
-
|
42
|
+
# TODO move this logic to a domain extension
|
43
|
+
{domain} = application
|
44
|
+
|
45
|
+
injection = core.inject(widgets_options).fail flow.failed
|
60
46
|
|
61
|
-
|
47
|
+
domain?[transition.to]?.ready ||= injection.done
|
62
48
|
|
63
49
|
# To prevent reinstation upon changing to this state for the
|
64
50
|
# second time, delete stored configuration for this state
|
65
51
|
delete states[transition.to]
|
66
52
|
|
53
|
+
normalize_widget_options: (unormalized_widget_options, transition_widgets_options) ->
|
54
|
+
widgets = []
|
55
|
+
|
56
|
+
for name, options of unormalized_widget_options
|
57
|
+
widget_name = options.name || name
|
58
|
+
options.resource ||= name unless name == widget_name
|
59
|
+
|
60
|
+
# To allow user controlling the application change the
|
61
|
+
# widget configuration at runtime, we check the transition
|
62
|
+
# for widget options
|
63
|
+
widgets.push
|
64
|
+
name: widget_name
|
65
|
+
options: core.util.extend transition_widgets_options[widget_name], options
|
66
|
+
|
67
|
+
# TODO document why we delete this?
|
68
|
+
delete options.name
|
69
|
+
|
70
|
+
widgets
|
67
71
|
|
68
72
|
failed: (exception) ->
|
69
73
|
logger.error "states.flow.failed: Failed autostarting widget! \n Message: #{exception.message}", exception
|
70
74
|
|
71
75
|
|
72
|
-
version: '0.2.
|
76
|
+
version: '0.2.3'
|
73
77
|
|
74
78
|
initialize: (application) ->
|
75
79
|
mediator.on 'state.change' , state.change
|
76
80
|
mediator.on 'state.changed', state.changed
|
77
81
|
|
78
82
|
# TODO load widgets before state.changed, load on state.change
|
79
|
-
|
83
|
+
# TODO use function hanlder
|
84
|
+
mediator.on 'state.changed', -> flow.changed arguments...
|
80
85
|
|
81
86
|
# TODO better integration with router to remove initial states widgets
|
82
87
|
mediator.on 'states.list', ->
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
require ['jquery'], ($) ->
|
2
|
+
# TODO use prefilter instead of beforeSend
|
3
|
+
# $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
|
4
|
+
$.ajaxSetup
|
5
|
+
beforeSend: (xhr) ->
|
6
|
+
token = $('meta[name="csrf-token"]').attr('content')
|
7
|
+
token and xhr.setRequestHeader 'X-CSRF-Token', token
|
@@ -1,6 +1,5 @@
|
|
1
1
|
#= require require/require
|
2
2
|
#= require build
|
3
|
-
#= require ./jquery
|
4
3
|
# TODO Move this file outside the initializers folder
|
5
4
|
|
6
5
|
root = exports ? this
|
@@ -9,14 +8,18 @@ root = exports ? this
|
|
9
8
|
# it and globalize it, because aurajs does not know we are using
|
10
9
|
# component.io loader and thinks jquery must be shipped within it
|
11
10
|
# TODO think in away to not use a global jquery
|
12
|
-
try
|
13
|
-
|
14
|
-
catch e
|
11
|
+
# try
|
12
|
+
# root.jQuery = root.$ = require 'component-jquery'
|
13
|
+
# catch e
|
15
14
|
# jQuery was not included in the component build, soo the application will fallback to the
|
16
15
|
# jquery builded in aurajs
|
17
16
|
|
17
|
+
define 'jquery', [], -> require 'component-jquery'
|
18
|
+
root.jQuery = root.$ = require 'component-jquery'
|
19
|
+
|
18
20
|
# This may be included in build, and loaded before aurajs requires for them
|
19
21
|
# TODO also preload underscorejs
|
22
|
+
# define 'underscore', require 'lodash'
|
20
23
|
# TODO also preload eventemitter2
|
21
24
|
# TODO also preload require-jstext
|
22
25
|
|
@@ -7,15 +7,20 @@ define [
|
|
7
7
|
'/assets/jquery/inview',
|
8
8
|
'stampit/stampit'], (templates, presenter, inview, stampit) ->
|
9
9
|
|
10
|
-
observable = require('
|
10
|
+
observable = require('observable').mixin
|
11
|
+
advisable = require('advisable').mixin
|
11
12
|
|
12
13
|
# TODO define componentjs required packages, as requirejs packages
|
13
14
|
stampit ||= require 'stampit/stampit'
|
14
15
|
|
15
16
|
scopable = (widget) ->
|
17
|
+
deferred = widget.sandbox.data.deferred()
|
18
|
+
|
16
19
|
# TODO add widget plug-in as an extension for a widget
|
17
20
|
require ['widgets/viewer/plugins/scopable'], (scopable) ->
|
18
|
-
scopable widget
|
21
|
+
deferred.resolveWith scopable, [scopable widget]
|
22
|
+
|
23
|
+
deferred
|
19
24
|
|
20
25
|
paginable = stampit
|
21
26
|
flip_to: (page) ->
|
@@ -154,7 +159,7 @@ define [
|
|
154
159
|
|
155
160
|
# We extend presentation.selected just to assign all values of the item model
|
156
161
|
# TODO call presenter to do this job
|
157
|
-
@sandbox.util.extend @presentation.selected , item.model
|
162
|
+
@sandbox.util.extend @presentation.selected , item.model.json?() || item.model
|
158
163
|
@sandbox.emit "viewer.#{@identifier}.selected", item.model
|
159
164
|
|
160
165
|
scope_to: (scope, child_scope) ->
|
@@ -167,6 +172,11 @@ define [
|
|
167
172
|
|
168
173
|
@sandbox.emit "viewer.#{@identifier}.scope_changed", @scope
|
169
174
|
|
175
|
+
# TODO better scope data binding, and updating
|
176
|
+
if @view? and scope.scope?.data
|
177
|
+
@view.update
|
178
|
+
scope_data: observable scope.scope.data
|
179
|
+
|
170
180
|
@repopulate()
|
171
181
|
|
172
182
|
repopulate: ->
|
@@ -175,7 +185,7 @@ define [
|
|
175
185
|
@load.stop()
|
176
186
|
@load = null
|
177
187
|
else
|
178
|
-
@fetching?.abort()
|
188
|
+
@fetching?.abort?()
|
179
189
|
|
180
190
|
# TODO store spinner instance, instead of creating a new one every time
|
181
191
|
unless @load?
|
@@ -212,7 +222,7 @@ define [
|
|
212
222
|
@$el.addClass 'empty'
|
213
223
|
@$el.removeClass 'filled'
|
214
224
|
|
215
|
-
@sandbox.emit "viewer.#{@identifier}.populated", records
|
225
|
+
@sandbox.emit "viewer.#{@identifier}.populated", records, @
|
216
226
|
|
217
227
|
@fetching.always =>
|
218
228
|
# TODO implement status for viewer widget
|
@@ -254,7 +264,7 @@ define [
|
|
254
264
|
|
255
265
|
@load.stop()
|
256
266
|
|
257
|
-
@presentation = @presenter records
|
267
|
+
@presentation = @presenter records, @scope
|
258
268
|
|
259
269
|
@$el.html templates[@options.resource]
|
260
270
|
|
@@ -274,7 +284,7 @@ define [
|
|
274
284
|
|
275
285
|
@handles 'click', 'back', '.back'
|
276
286
|
|
277
|
-
@sandbox.emit "viewer.#{@identifier}.populated", records
|
287
|
+
@sandbox.emit "viewer.#{@identifier}.populated", records, @
|
278
288
|
|
279
289
|
|
280
290
|
deferred.fail =>
|
@@ -283,10 +293,13 @@ define [
|
|
283
293
|
|
284
294
|
|
285
295
|
plugins: (options) ->
|
296
|
+
deferreds = []
|
286
297
|
|
287
|
-
paginable widget: @ if options.page
|
288
|
-
scrollable widget: @ if options.scroll
|
289
|
-
scopable @ if options.scope or options.scopable
|
298
|
+
deferreds.push paginable widget: @ if options.page
|
299
|
+
deferreds.push scrollable widget: @ if options.scroll
|
300
|
+
deferreds.push scopable @ if options.scope or options.scopable
|
301
|
+
|
302
|
+
@sandbox.data.when deferreds...
|
290
303
|
|
291
304
|
# TODO move this method to an extension
|
292
305
|
syncronize_children: ->
|
@@ -308,10 +321,11 @@ define [
|
|
308
321
|
element.setAttribute 'aura-widget', current
|
309
322
|
|
310
323
|
# TODO move this method to an extension
|
311
|
-
# TODO listen for future parent presentation changes
|
312
324
|
inherit_parent_presentation: ->
|
313
325
|
return unless view = @sandbox?._parent?._view
|
326
|
+
advisable view unless view.after?
|
314
327
|
|
328
|
+
# TODO move this method to sandbox
|
315
329
|
isDescendant = (parent, child) ->
|
316
330
|
node = child.parentNode
|
317
331
|
|
@@ -321,24 +335,63 @@ define [
|
|
321
335
|
|
322
336
|
false
|
323
337
|
|
324
|
-
|
338
|
+
inherited = []
|
325
339
|
# Copy default models
|
326
340
|
# TODO think if its a good idea to notify about model name conflicts
|
327
|
-
for name, model of view.models
|
328
|
-
@presentation[name]
|
341
|
+
for name, model of view.models when not @presentation[name] # By default do not override child models with parent models
|
342
|
+
@presentation[name] = model
|
343
|
+
inherited.push name
|
344
|
+
|
345
|
+
# TODO store bindings instead of searching every time
|
346
|
+
for binding in view.bindings when binding.iterated
|
347
|
+
for subview in binding.iterated
|
348
|
+
if isDescendant subview.els[0], @$el.get(0)
|
349
|
+
for name, model of subview.models when not @presentation[name]
|
350
|
+
advisable subview
|
351
|
+
@presentation[name] = model
|
352
|
+
inherited.push name
|
353
|
+
|
354
|
+
break
|
329
355
|
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
for view in binding.iterated
|
334
|
-
if isDescendant view.els[0], @$el.get(0)
|
335
|
-
for name, model of view.models
|
336
|
-
@presentation[name] ||= model
|
356
|
+
# Schedule update of copied models
|
357
|
+
view.after 'update', (models) =>
|
358
|
+
@update_inherited_models view, models, inherited
|
337
359
|
|
338
|
-
|
360
|
+
subview.after 'update', (models) =>
|
361
|
+
@update_inherited_models view, models, inherited
|
339
362
|
|
340
363
|
true
|
341
364
|
|
365
|
+
update_inherited_models: (parent, models, inherited) ->
|
366
|
+
# Only update inherited models
|
367
|
+
models = @sandbox.util._.pick models, inherited
|
368
|
+
|
369
|
+
isDescendant = (parent, child) ->
|
370
|
+
node = child.parentNode
|
371
|
+
|
372
|
+
while (node != null)
|
373
|
+
return true if (node == parent)
|
374
|
+
node = node.parentNode
|
375
|
+
|
376
|
+
false
|
377
|
+
|
378
|
+
# Copy default models
|
379
|
+
# TODO think if its a good idea to notify about model name conflicts
|
380
|
+
for name, model of models
|
381
|
+
@presentation[name] = model
|
382
|
+
|
383
|
+
@view.update models
|
384
|
+
|
385
|
+
# TODO store bindings instead of searching every time
|
386
|
+
for binding in parent.bindings when binding.iterated
|
387
|
+
for subview in binding.iterated
|
388
|
+
if isDescendant subview.els[0], @$el.get(0)
|
389
|
+
models = @sandbox.util._.pick subview.models, inherited
|
390
|
+
@view.update models
|
391
|
+
@presentation[name] = model for model in models
|
392
|
+
break
|
393
|
+
|
394
|
+
true
|
342
395
|
|
343
396
|
initialize: (options) ->
|
344
397
|
# TODO import core extensions in another place
|
@@ -349,10 +402,14 @@ define [
|
|
349
402
|
@sandbox.on "viewer.#{@identifier}.scope", @scope_to, @
|
350
403
|
|
351
404
|
# Iniitalize plugins
|
352
|
-
@plugins options
|
405
|
+
loading = @plugins options
|
353
406
|
|
354
407
|
@$el.addClass "viewer widget #{cssify @identifier} idle clearfix"
|
355
408
|
|
409
|
+
loading.done =>
|
410
|
+
@require_custom options
|
411
|
+
|
412
|
+
require_custom: (options) ->
|
356
413
|
# Fetch custom templates
|
357
414
|
# TODO better custom templates structure and custom presenter
|
358
415
|
# TODO better segregation of concerns on this code
|