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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a43d1f2847080ff697b021741b23c5e8f70a2d2d
4
- data.tar.gz: e95635f01eef3bbd4a12c3e8ebc567d4166a390c
3
+ metadata.gz: 0f81a5afa3210fac75452451a82198e1ddfdf83b
4
+ data.tar.gz: 7aeb495dce92136c0e1e3ff165e9410dfb201836
5
5
  SHA512:
6
- metadata.gz: 9d61938ca51a95be7a1f48ccae19e85644bbdbcbc9f85b5689966864f0962c5aba93471d886a46c2b785803538566d59d77cab913d96ee8c8879321ba1f66023
7
- data.tar.gz: f9f8a934fe14328409c26e0065f3bd76e8d5cc5fa4f99e494471e56e2ac2edb2525543c60237201eb3ded8ee88f4f10ef3e07a5463f17be996b4164d4e4fd793
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__
@@ -0,0 +1,3 @@
1
+ 'use strict'
2
+
3
+ define 'aura/presenterable', ['stampit/stampit'], (stampit) -> stampit()
@@ -3,6 +3,8 @@
3
3
  define ->
4
4
 
5
5
  dialog_extensions =
6
+ close_template: '<a class="close">&times;</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' unless options.autoshow
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: @options.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
- presented = @scope.fetch null, (records) ->
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
- if @options.records?
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
- deferred.done (records) =>
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 viewer presenteer
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
- observable = require('observable').mixin
7
- extend = require 'segmentio-extend'
8
- self = null
9
- view = null
9
+ define ['stampit/stampit'], (stampit) ->
10
10
 
11
- normalizer =
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
- drawings: ->
22
- selection = view.select (binding) ->
23
- binding.keypath == 'items'
13
+ viewer = (items) ->
14
+ observable items: _.map items, itemable
24
15
 
25
- items_binding = selection[0]
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
- presented: (v) -> view = v
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
- <div class="image" data-html="item.image"></div>
4
+ <img class="image" data-src="item.source">
5
5
  </div>
6
6
  </div>
data/lib/ende/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ende
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
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.7
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-03 00:00:00.000000000 Z
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