ende 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/assets/javascripts/aura/extensions/widget/presentable.js.coffee +24 -0
- data/lib/assets/javascripts/aura/presentable.js.coffee +3 -0
- data/lib/assets/javascripts/widgets/dialog/main.js.coffee +11 -2
- data/lib/assets/javascripts/widgets/viewer/main.js.coffee +32 -9
- data/lib/assets/javascripts/widgets/viewer/presenters/default.js.coffee +11 -44
- data/lib/assets/javascripts/widgets/viewer/states/default.html +1 -1
- data/lib/ende/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f81a5afa3210fac75452451a82198e1ddfdf83b
|
4
|
+
data.tar.gz: 7aeb495dce92136c0e1e3ff165e9410dfb201836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48563ccd10da8cf8481d1314ed381d53bed38cae72d8c0797dc0eea4f5acacd66f75b6d85f5b39e1a5e7a4b131c83225d18ddb561f6baf27583272b792b95ad4
|
7
|
+
data.tar.gz: 330bc4c64bf3fef112fb874ff07ca5baf4f3d126e8a3081d384f5b8e1e1c053b2a96db6e048690a9ffe22873dbacf2510fb1cbfd6c8d898bfe45548f998c5f77
|
@@ -0,0 +1,24 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
# TODO finish this extension
|
4
|
+
# TODO initialize dependent extensions
|
5
|
+
define 'aura/extensions/widget/presentable', ['advisable'] ->
|
6
|
+
|
7
|
+
presentable =
|
8
|
+
constructor: (options) ->
|
9
|
+
presentable.super.constructor.call @, options
|
10
|
+
|
11
|
+
@after 'initialized', =>
|
12
|
+
@presenter?.sandbox = @sandbox
|
13
|
+
|
14
|
+
(application) ->
|
15
|
+
|
16
|
+
version: '0.2.0'
|
17
|
+
|
18
|
+
initialize: (application) ->
|
19
|
+
{core} = application
|
20
|
+
|
21
|
+
# Add support for element removal after stoping widget
|
22
|
+
# TODO replace Base.extend inheritance to stampit composition
|
23
|
+
core.Widgets.Base = core.Widgets.Base.extend presentable
|
24
|
+
recyclable.super = core.Widgets.Base.__super__
|
@@ -3,6 +3,8 @@
|
|
3
3
|
define ->
|
4
4
|
|
5
5
|
dialog_extensions =
|
6
|
+
close_template: '<a class="close">×</a>'
|
7
|
+
|
6
8
|
positionate: ->
|
7
9
|
@el.css marginLeft: -(this.el.width() / 2) + 'px'
|
8
10
|
|
@@ -31,13 +33,17 @@ define ->
|
|
31
33
|
{sandbox, $el: el} = widget
|
32
34
|
@el = el
|
33
35
|
|
34
|
-
el.addClass 'hide'
|
36
|
+
el.addClass 'hide' unless options.autoshow
|
35
37
|
|
36
38
|
sandbox.inject options.content
|
37
39
|
|
38
40
|
sandbox.once "#{child.name}.#{child.identifier || 'default'}.started", (widget) =>
|
39
41
|
@positionate()
|
40
42
|
|
43
|
+
# TODO better close html creation and handling
|
44
|
+
el.prepend @close_template if options.closable
|
45
|
+
|
46
|
+
# TODO use urls on hrefs istead of binding events
|
41
47
|
el.find('.close').click (event) =>
|
42
48
|
@emit 'close'
|
43
49
|
@hide()
|
@@ -47,6 +53,8 @@ define ->
|
|
47
53
|
|
48
54
|
dialog: null
|
49
55
|
|
56
|
+
version: '0.1.0'
|
57
|
+
|
50
58
|
options:
|
51
59
|
|
52
60
|
autoshow: false
|
@@ -66,7 +74,8 @@ define ->
|
|
66
74
|
widget_options = @extract_options()
|
67
75
|
@dialog = new dialog
|
68
76
|
widget: @, # TODO forward only element of the widget
|
69
|
-
autoshow:
|
77
|
+
autoshow: options.autoshow
|
78
|
+
closable: options.closable
|
70
79
|
content: widget_options
|
71
80
|
|
72
81
|
# TODO forward only element of the widget
|
@@ -58,7 +58,12 @@ define ['./states/index', './presenters/default', '/assets/jquery/inview'], (tem
|
|
58
58
|
# TODO Current remote page that is beign displayed
|
59
59
|
options:
|
60
60
|
resource: 'default'
|
61
|
+
|
62
|
+
# TODO rename records to resource
|
61
63
|
records: null
|
64
|
+
|
65
|
+
# Use to fetch records from an attribute instead of all
|
66
|
+
attribute: null
|
62
67
|
# page:
|
63
68
|
# current: 1
|
64
69
|
# per : 5
|
@@ -78,7 +83,7 @@ define ['./states/index', './presenters/default', '/assets/jquery/inview'], (tem
|
|
78
83
|
@sandbox.emit "viewer.#{@identifier}.selected", item.model
|
79
84
|
|
80
85
|
scope_to: (scope, child_scope) ->
|
81
|
-
throw new TypeError "Invalid scope sent to viewer@#{@identifier} sent: #{scope.resource}, expected: #{@scope.resource}" if scope.resource != @scope.resource
|
86
|
+
throw new TypeError "Invalid scope sent to viewer@#{@identifier} sent: #{scope.resource}, expected: #{@scope.resource}" if scope.resource.toString() != @scope.resource.toString()
|
82
87
|
@scope = scope
|
83
88
|
|
84
89
|
# TODO better hierachical event distribution
|
@@ -101,7 +106,9 @@ define ['./states/index', './presenters/default', '/assets/jquery/inview'], (tem
|
|
101
106
|
|
102
107
|
# ✔ Generalize this filtering option
|
103
108
|
# TODO make scope.all method use scope too, and replace @scope.fetch by it
|
104
|
-
|
109
|
+
options = @options # TODO better options accessing
|
110
|
+
presented = @scope.fetch null, (result) ->
|
111
|
+
records = if options.attribute? then result[options.attribute] else result
|
105
112
|
records = _.map records, @, @
|
106
113
|
|
107
114
|
# TODO implement Array.concat ou Array.merge in observer, and
|
@@ -122,20 +129,36 @@ define ['./states/index', './presenters/default', '/assets/jquery/inview'], (tem
|
|
122
129
|
@load.stop()
|
123
130
|
@load = null
|
124
131
|
|
125
|
-
|
126
132
|
populate: (handlers) ->
|
127
133
|
sandbox = @sandbox
|
128
134
|
|
129
135
|
@load = @sandbox.ui.loader @results
|
130
136
|
|
131
|
-
|
137
|
+
|
138
|
+
# TODO replace with strategy pattern, please!
|
139
|
+
if @options.records?.length
|
140
|
+
|
132
141
|
deferred = jQuery.Deferred()
|
133
142
|
deferred.resolveWith @scope, [@options.records]
|
143
|
+
|
144
|
+
else if @options.attribute
|
145
|
+
|
146
|
+
deferred = @scope.reload?()
|
147
|
+
|
148
|
+
# TODO better threating this case!
|
149
|
+
unless deferred
|
150
|
+
deferred = jQuery.Deferred()
|
151
|
+
empty = {}
|
152
|
+
empty[@options.attribute] = []
|
153
|
+
deferred.resolveWith @scope, [empty]
|
154
|
+
|
134
155
|
else
|
135
156
|
deferred = @scope.all()
|
136
157
|
|
137
158
|
# Initialize dependencies
|
138
|
-
|
159
|
+
# TODO replace with strategy pattern, please!
|
160
|
+
deferred.done (result) =>
|
161
|
+
records = if @options.attribute? then result[@options.attribute] else result
|
139
162
|
|
140
163
|
@load.stop()
|
141
164
|
|
@@ -154,16 +177,16 @@ define ['./states/index', './presenters/default', '/assets/jquery/inview'], (tem
|
|
154
177
|
|
155
178
|
@handles 'click', 'back', '.back'
|
156
179
|
|
180
|
+
deferred.fail =>
|
181
|
+
# TODO better error message and viewer status
|
182
|
+
@html 'Failed to fetch data from server.'
|
183
|
+
|
157
184
|
initialize: (options) ->
|
158
185
|
# TODO import core extensions in another place
|
159
186
|
@scope = model = @sandbox.resource options.resource
|
160
187
|
cssify = @sandbox.util.inflector.cssify
|
161
188
|
@sandbox.on "viewer.#{@identifier}.scope", @scope_to, @
|
162
189
|
|
163
|
-
# Extend presentation
|
164
|
-
# TODO execute only one time
|
165
|
-
presenter.drawing = @sandbox.modacad.drawing
|
166
|
-
|
167
190
|
# TODO Initialize pagination settings
|
168
191
|
# @page = options.page
|
169
192
|
|
@@ -1,52 +1,19 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
-
# TODO implement default
|
4
|
-
define () ->
|
3
|
+
# TODO implement default presenter
|
4
|
+
# define ['aura/presenterable'], (presenterable) ->
|
5
|
+
# presenterable()
|
6
|
+
# TODO move observable to requirejs
|
7
|
+
observable = require('observable').mixin
|
5
8
|
|
6
|
-
|
7
|
-
extend = require 'segmentio-extend'
|
8
|
-
self = null
|
9
|
-
view = null
|
9
|
+
define ['stampit/stampit'], (stampit) ->
|
10
10
|
|
11
|
-
|
12
|
-
normalize: (model) ->
|
13
|
-
observable extend
|
14
|
-
name : model.code
|
15
|
-
image : null
|
16
|
-
selected : false
|
17
|
-
model : model
|
18
|
-
normalized : true
|
19
|
-
, self.handlers.item
|
11
|
+
itemable = stampit().enclose -> observable @
|
20
12
|
|
21
|
-
|
22
|
-
|
23
|
-
binding.keypath == 'items'
|
13
|
+
viewer = (items) ->
|
14
|
+
observable items: _.map items, itemable
|
24
15
|
|
25
|
-
|
16
|
+
(items) ->
|
26
17
|
|
27
|
-
for item_view in items_binding.iterated
|
28
|
-
selection = item_view.select (binding) ->
|
29
|
-
binding.keypath == 'image'
|
30
|
-
|
31
|
-
image_binding = selection[0]
|
32
|
-
drawing = self.drawing $(image_binding.el), image_binding.model.model
|
33
|
-
drawing.width = (parseInt(drawing.width ) / 4) + 'px'
|
34
|
-
drawing.height = (parseInt(drawing.height) / 4) + 'px'
|
35
|
-
|
36
|
-
self = (items) ->
|
37
|
-
|
38
|
-
# TODO create view_model
|
39
18
|
presentation =
|
40
|
-
|
41
|
-
viewer: observable
|
42
|
-
items: self._.map items, normalizer.normalize
|
43
|
-
|
44
|
-
presentation.viewer.subscribe 'items', (items) ->
|
45
|
-
for item in items
|
46
|
-
unless item.normalized
|
47
|
-
index = @items.indexOf item
|
48
|
-
@observed.items[index] = normalizer.normalize item
|
49
|
-
|
50
|
-
normalizer.drawings()
|
51
|
-
|
52
|
-
presentation
|
19
|
+
viewer: viewer items
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<div class="items">
|
2
2
|
<div class="item" data-each-item="viewer.items" data-class-selected="item.selected" data-on-click="item.clicked">
|
3
3
|
<div data-html="item.name" ></div>
|
4
|
-
<
|
4
|
+
<img class="image" data-src="item.source">
|
5
5
|
</div>
|
6
6
|
</div>
|
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.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heitor Salazar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,6 +79,8 @@ files:
|
|
79
79
|
- lib/assets/javascripts/aura/extensions/states.js.coffee
|
80
80
|
- lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee
|
81
81
|
- lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee
|
82
|
+
- lib/assets/javascripts/aura/extensions/widget/presentable.js.coffee
|
83
|
+
- lib/assets/javascripts/aura/presentable.js.coffee
|
82
84
|
- lib/assets/javascripts/config/initializers/jquery.js.coffee
|
83
85
|
- lib/assets/javascripts/config/initializers/load_components.js.coffee
|
84
86
|
- lib/assets/javascripts/config/initializers/requirejs.js.coffee
|