ende 0.4.24 → 0.4.25
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/lib/assets/javascripts/aura/extensions/stamps/stampit.js +718 -0
- data/lib/assets/javascripts/aura/extensions/stamps.js.coffee +35 -0
- data/lib/assets/javascripts/aura/extensions/states.js.coffee +27 -25
- data/lib/assets/javascripts/aura/extensions/widget/composable.js.coffee +152 -0
- data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +23 -28
- data/lib/assets/javascripts/aura/extensions/widget/flowable.js.coffee +65 -0
- data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +34 -21
- data/lib/assets/javascripts/aura/extensions/widget/napable.js.coffee +13 -17
- data/lib/assets/javascripts/widgets/dialog/main.js.coffee +2 -1
- data/lib/assets/javascripts/widgets/viewer/main.js.coffee +111 -44
- data/lib/ende/version.rb +1 -1
- metadata +6 -2
@@ -1,14 +1,13 @@
|
|
1
|
-
|
2
1
|
'use strict';
|
3
2
|
|
4
|
-
|
3
|
+
lazy_require = 'advisable'
|
5
4
|
define [
|
6
5
|
'./states/index',
|
7
6
|
'./presenters/default',
|
8
7
|
'jquery.inview',
|
9
8
|
'stampit/stampit',
|
10
|
-
|
11
|
-
|
9
|
+
'observable',
|
10
|
+
lazy_require], (templates, presenter, inview, stampit, observable, advisable) ->
|
12
11
|
|
13
12
|
scopable = (widget) ->
|
14
13
|
deferred = widget.sandbox.data.deferred()
|
@@ -30,6 +29,7 @@ define [
|
|
30
29
|
|
31
30
|
return unless total_pages?
|
32
31
|
|
32
|
+
# TODO set default abortion to decreatse page numbers amount
|
33
33
|
scope.page ++page_number
|
34
34
|
|
35
35
|
if page_number <= total_pages
|
@@ -64,7 +64,7 @@ define [
|
|
64
64
|
scrolled: ->
|
65
65
|
@widget.sandbox.emit "#{@widget.name}.#{@widget.identifier}.flip" if @bottoned()
|
66
66
|
,
|
67
|
-
buffer:
|
67
|
+
buffer: 400
|
68
68
|
, ->
|
69
69
|
@scroll_container = $ window
|
70
70
|
|
@@ -126,7 +126,32 @@ define [
|
|
126
126
|
viewed: (event, in_view, horizontal, vertical) ->
|
127
127
|
boo[if in_view then 'pride' else 'shame'] event.target
|
128
128
|
|
129
|
-
|
129
|
+
|
130
|
+
# TODO Move each handler to independent features
|
131
|
+
handleable = stampit
|
132
|
+
handleables:
|
133
|
+
item:
|
134
|
+
hover: (event, models) ->
|
135
|
+
if event.type == 'mouseenter'
|
136
|
+
@hover models.item
|
137
|
+
else if event.type == 'mouseleave'
|
138
|
+
@hover null
|
139
|
+
else
|
140
|
+
throw new TypeError 'viewer.handlers.hover: Event type incompatible with hovering.'
|
141
|
+
|
142
|
+
clicked: (event, models) -> @select models.item
|
143
|
+
|
144
|
+
, {}, ->
|
145
|
+
|
146
|
+
throw new TypeError "Widget property is mandatory for handleable stamp" unless @widget?
|
147
|
+
|
148
|
+
@handlers =
|
149
|
+
item:
|
150
|
+
clicked: $.proxy @handleables.item.clicked, @widget
|
151
|
+
hover : $.proxy @handleables.item.hover , @widget
|
152
|
+
|
153
|
+
@
|
154
|
+
version: '0.2.4'
|
130
155
|
|
131
156
|
# TODO better separation of concerns
|
132
157
|
# TODO Current remote page that is beign displayed
|
@@ -157,8 +182,16 @@ define [
|
|
157
182
|
# We extend presentation.selected just to assign all values of the item model
|
158
183
|
# TODO call presenter to do this job
|
159
184
|
@sandbox.util.extend @presentation.selected , item.model.json?() || item.model
|
185
|
+
|
186
|
+
# TODO change paramters to item, item.model
|
160
187
|
@sandbox.emit "viewer.#{@identifier}.selected", item.model
|
161
188
|
|
189
|
+
# Called when hover in and out from model
|
190
|
+
hover: (item) ->
|
191
|
+
# TODO call presenter to do this job
|
192
|
+
# @sandbox.util.extend @presentation.hovered , item.model.json?() || item.model
|
193
|
+
@sandbox.emit "viewer.#{@identifier}.hovered", item, item && item.model
|
194
|
+
|
162
195
|
scope_to: (scope, child_scope) ->
|
163
196
|
# Singuralize in order to accept association scopes, since
|
164
197
|
# association scopes return almost the same kind as of it's
|
@@ -166,16 +199,14 @@ define [
|
|
166
199
|
sent_scope = @inflector.singularize scope.resource.toString()
|
167
200
|
current_scope = @inflector.singularize @scope.resource.toString()
|
168
201
|
|
202
|
+
deferred = @sandbox.data.deferred()
|
203
|
+
|
169
204
|
if sent_scope != current_scope
|
170
205
|
throw new TypeError "Invalid scope sent to viewer@#{@identifier} sent: '#{sent_scope}', expected: '#{current_scope}'"
|
171
206
|
|
172
207
|
# For sobsequent usages we must store the scope
|
173
208
|
@scope = scope
|
174
209
|
|
175
|
-
# TODO better hierachical event distribution
|
176
|
-
for { _widget: widget } in @sandbox._children?
|
177
|
-
widget.scope_to? child_scope
|
178
|
-
|
179
210
|
@sandbox.emit "viewer.#{@identifier}.scope_changed", @scope
|
180
211
|
|
181
212
|
# TODO better scope data binding, and updating
|
@@ -185,6 +216,15 @@ define [
|
|
185
216
|
|
186
217
|
@repopulate()
|
187
218
|
|
219
|
+
# TODO rename this method
|
220
|
+
# TODO also move this to an external tag
|
221
|
+
statused: (status) ->
|
222
|
+
if status
|
223
|
+
@status = status
|
224
|
+
@sandbox.emit "viewer.#{@identifier}.status_changed", status
|
225
|
+
else
|
226
|
+
@status
|
227
|
+
|
188
228
|
repopulate: ->
|
189
229
|
unless @fetching?
|
190
230
|
if @load?
|
@@ -195,9 +235,10 @@ define [
|
|
195
235
|
|
196
236
|
# TODO store spinner instance, instead of creating a new one every time
|
197
237
|
unless @load?
|
198
|
-
@load = @sandbox.ui.loader @$
|
238
|
+
@load = @sandbox.ui.loader @$results
|
199
239
|
|
200
240
|
# TODO implement status for viewer widget
|
241
|
+
@statused 'loading'
|
201
242
|
@$el.addClass 'idle'
|
202
243
|
@$el.removeClass 'loading'
|
203
244
|
|
@@ -212,12 +253,9 @@ define [
|
|
212
253
|
records = _.map records, @resource, @resource unless records[0]?.resource or records[0]?.itemable
|
213
254
|
|
214
255
|
# TODO implement Array.concat ou Array.merge in observer, and
|
215
|
-
# use it here instead of
|
256
|
+
# use it here instead of overriding all records
|
216
257
|
viewer.items = records
|
217
258
|
|
218
|
-
# Start widgets created by bindings
|
219
|
-
@syncronize_children()
|
220
|
-
|
221
259
|
@fetching.done (records) =>
|
222
260
|
if viewer.items.length
|
223
261
|
# boo.initialize @$el.find '.results .items'
|
@@ -231,21 +269,20 @@ define [
|
|
231
269
|
@sandbox.emit "viewer.#{@identifier}.populated", records, @
|
232
270
|
|
233
271
|
@fetching.always =>
|
234
|
-
# TODO implement status for viewer widget
|
235
|
-
@$el.addClass 'idle'
|
236
|
-
@$el.removeClass 'loading'
|
237
|
-
|
238
272
|
if @load?
|
239
273
|
@load.stop()
|
240
274
|
@load = null
|
241
275
|
|
276
|
+
# TODO implement status for viewer widget
|
277
|
+
@$el.removeClass 'loading'
|
278
|
+
@statused 'idle'
|
279
|
+
@$el.addClass 'idle'
|
242
280
|
|
243
|
-
populate:
|
244
|
-
|
245
|
-
|
246
|
-
@load = @sandbox.ui.loader @$results
|
281
|
+
populate: ->
|
282
|
+
@load = @sandbox.ui.loader @$el
|
247
283
|
|
248
284
|
# TODO implement status for viewer widget
|
285
|
+
@statused 'loading'
|
249
286
|
@$el.removeClass 'idle'
|
250
287
|
@$el.addClass 'loading'
|
251
288
|
|
@@ -270,9 +307,12 @@ define [
|
|
270
307
|
|
271
308
|
@load.stop()
|
272
309
|
|
273
|
-
|
310
|
+
# TODO do not send records as parameter
|
311
|
+
@presentation = @presenter records, @scope, @handleable
|
274
312
|
|
313
|
+
# Initialize elements
|
275
314
|
@$el.html templates[@options.resource]
|
315
|
+
@$results = @$el.find '.results .items'
|
276
316
|
|
277
317
|
if records.length
|
278
318
|
# boo.initialize @$el.find '.results .items'
|
@@ -282,7 +322,14 @@ define [
|
|
282
322
|
|
283
323
|
# TODO move binders to application
|
284
324
|
@inherit_parent_presentation()
|
285
|
-
|
325
|
+
# TODO on bind execute presentation_options method and extend and inherit from presenter what needed
|
326
|
+
@bind @presentation, @sandbox.util.extend(true, @presenter.presentation, @options.presentation)
|
327
|
+
|
328
|
+
@presentation.viewer.subscribe 'items', =>
|
329
|
+
# Start possible widgets created by items with widget
|
330
|
+
# instantiation markup
|
331
|
+
@syncronize_children()
|
332
|
+
|
286
333
|
|
287
334
|
# Start widgets that may have been created by bindings
|
288
335
|
@sandbox.emit 'aura.sandbox.start', @sandbox
|
@@ -299,7 +346,7 @@ define [
|
|
299
346
|
|
300
347
|
|
301
348
|
plugins: (options) ->
|
302
|
-
deferreds = []
|
349
|
+
deferreds = [@]
|
303
350
|
|
304
351
|
deferreds.push paginable widget: @ if options.page
|
305
352
|
deferreds.push scrollable widget: @ if options.scroll
|
@@ -310,6 +357,7 @@ define [
|
|
310
357
|
# TODO move this method to an extension
|
311
358
|
syncronize_children: ->
|
312
359
|
@sandbox._children ||= []
|
360
|
+
@sandbox._widget ||= @
|
313
361
|
|
314
362
|
# Add possible new childs
|
315
363
|
@constructor.startAll(@$el).done (widgets...) =>
|
@@ -319,6 +367,12 @@ define [
|
|
319
367
|
|
320
368
|
@sandbox._children = @sandbox._children.concat widgets
|
321
369
|
|
370
|
+
for widget in widgets
|
371
|
+
# TODO emit this event only when all siblings have initialized
|
372
|
+
@sandbox.emit "#{widget.name}.#{widget.identifier}.siblings_initialized", @sandbox._children
|
373
|
+
|
374
|
+
true
|
375
|
+
|
322
376
|
# TODO better internal aura widget selection
|
323
377
|
# Prevent other child to be instantiated
|
324
378
|
@$el.find('[data-aura-widget]').each (i, element) ->
|
@@ -402,43 +456,56 @@ define [
|
|
402
456
|
initialize: (options) ->
|
403
457
|
# TODO import core extensions in another place
|
404
458
|
@resource = @sandbox.resource options.resource
|
405
|
-
@scope =
|
459
|
+
@scope = @resource
|
460
|
+
|
461
|
+
# Instantiate it's on handleable factory
|
462
|
+
widget = @
|
463
|
+
widgetable = stampit().enclose -> @widget = widget; @
|
464
|
+
@handleable = stampit.compose widgetable, handleable
|
406
465
|
|
407
466
|
{sandbox: {util: {@inflector}}} = @
|
408
467
|
|
409
468
|
@sandbox.on "viewer.#{@identifier}.scope", @scope_to, @
|
410
469
|
|
411
|
-
#
|
470
|
+
# Initalize plugins
|
471
|
+
# TODO think how to implement plugins api
|
412
472
|
loading = @plugins options
|
413
473
|
|
474
|
+
@statused 'idle'
|
414
475
|
@$el.addClass "viewer widget #{@inflector.cssify @identifier} idle clearfix"
|
415
476
|
|
416
|
-
loading.done
|
477
|
+
loading.done (widget) ->
|
478
|
+
widget.require_custom options.resource
|
479
|
+
|
480
|
+
# TODO externalize this code to an extension
|
481
|
+
require_custom: (resource) ->
|
482
|
+
deferred = @sandbox.data.deferred()
|
417
483
|
|
418
|
-
require_custom: (options) ->
|
419
484
|
# Fetch custom templates
|
420
485
|
# TODO better custom templates structure and custom presenter
|
421
486
|
# TODO better segregation of concerns on this code
|
422
487
|
# TODO handle case where custom presenter does not exist!
|
423
488
|
require [
|
424
|
-
"text!./widgets/viewer/templates/default/#{
|
425
|
-
"./widgets/viewer/presenters/#{
|
489
|
+
"text!./widgets/viewer/templates/default/#{resource}.html"
|
490
|
+
"./widgets/viewer/presenters/#{resource}"
|
426
491
|
], (custom_default_template, custom_presenter) =>
|
427
492
|
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
@select models.item
|
493
|
+
unless presenter.hasOwnProperty 'handlers'
|
494
|
+
Object.defineProperty presenter, 'handlers',
|
495
|
+
get: -> throw new Error "presenter.hanlder is deprecated, please compose upon handleable"
|
496
|
+
set: -> throw new Error "presenter.hanlder is deprecated, please compose upon handleable"
|
433
497
|
|
434
|
-
|
498
|
+
custom_default_template and templates[resource] = custom_default_template
|
499
|
+
@presenter = @sandbox.util.extend custom_presenter, presenter if custom_presenter
|
435
500
|
|
436
|
-
|
437
|
-
@
|
501
|
+
# Fetch default data
|
502
|
+
@populate()
|
438
503
|
|
439
|
-
|
504
|
+
deferred.resolveWith @, [resource]
|
440
505
|
|
441
|
-
|
442
|
-
|
506
|
+
, (error) =>
|
507
|
+
# TODO handle other status codes with xhr error
|
508
|
+
@sandbox.logger.error "Error when loading presenter and template for resource '#{resource}':\n\n", error.message + "\n\n", error
|
509
|
+
deferred.rejectWith @, arguments
|
443
510
|
|
444
|
-
|
511
|
+
deferred
|
data/lib/ende/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ende
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heitor Salazar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,8 +82,12 @@ files:
|
|
82
82
|
- lib/assets/javascripts/aura/extensions/rivets/formatters.js.coffee
|
83
83
|
- lib/assets/javascripts/aura/extensions/routes.js.coffee
|
84
84
|
- lib/assets/javascripts/aura/extensions/screening.js.coffee
|
85
|
+
- lib/assets/javascripts/aura/extensions/stamps.js.coffee
|
86
|
+
- lib/assets/javascripts/aura/extensions/stamps/stampit.js
|
85
87
|
- lib/assets/javascripts/aura/extensions/states.js.coffee
|
88
|
+
- lib/assets/javascripts/aura/extensions/widget/composable.js.coffee
|
86
89
|
- lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee
|
90
|
+
- lib/assets/javascripts/aura/extensions/widget/flowable.js.coffee
|
87
91
|
- lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee
|
88
92
|
- lib/assets/javascripts/aura/extensions/widget/napable.js.coffee
|
89
93
|
- lib/assets/javascripts/aura/extensions/widget/presentable.js.coffee
|