ende 0.4.20 → 0.4.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -3
  3. data/build/build.css +111 -0
  4. data/component.json +1 -0
  5. data/lib/assets/javascripts/aura/extensions/models.js.coffee.erb +4 -13
  6. data/lib/assets/javascripts/aura/extensions/platform.js.coffee +2 -8
  7. data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +21 -10
  8. data/lib/assets/javascripts/aura/extensions/states.js.coffee +25 -27
  9. data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +28 -23
  10. data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +21 -34
  11. data/lib/assets/javascripts/aura/extensions/widget/napable.js.coffee +17 -13
  12. data/lib/assets/javascripts/config/load_components.js.coffee +5 -7
  13. data/lib/assets/javascripts/widgets/dialog/main.js.coffee +1 -2
  14. data/lib/assets/javascripts/widgets/list/presenter.js.coffee +5 -4
  15. data/lib/assets/javascripts/widgets/support/adapters/olark.js +1 -1
  16. data/lib/assets/javascripts/widgets/tray/main.js.coffee +16 -22
  17. data/lib/assets/javascripts/widgets/viewer/main.js.coffee +39 -102
  18. data/lib/assets/javascripts/widgets/viewer/plugins/scopable.js.coffee +7 -1
  19. data/lib/ende/version.rb +1 -1
  20. data/vendor/assets/components/ende_build.js +5732 -1047
  21. data/vendor/components/indefinido-indemma/build/development.js +2 -2
  22. data/vendor/components/indefinido-indemma/build/release.js +9 -4
  23. data/vendor/components/indefinido-indemma/build/test.js +115 -21916
  24. data/vendor/components/indefinido-indemma/component.json +0 -1
  25. data/vendor/components/indefinido-indemma/lib/record/restfulable.js +7 -2
  26. data/vendor/components/indefinido-indemma/lib/record/validatable.js +2 -2
  27. data/vendor/components/indefinido-indemma/src/lib/record/persistable.coffee +2 -0
  28. data/vendor/components/indefinido-indemma/src/lib/record/resource.coffee +3 -2
  29. data/vendor/components/indefinido-indemma/src/lib/record/restfulable.coffee +16 -4
  30. data/vendor/components/indefinido-indemma/src/lib/record/validatable.coffee +3 -3
  31. data/vendor/components/indefinido-observable/.gitignore +15 -0
  32. data/vendor/components/indefinido-observable/.ruby-gemset +1 -0
  33. data/vendor/components/indefinido-observable/.ruby-version +1 -0
  34. data/vendor/components/indefinido-observable/Gemfile +13 -0
  35. data/vendor/components/indefinido-observable/Guardfile +39 -0
  36. data/vendor/components/indefinido-observable/History.md +0 -0
  37. data/vendor/components/indefinido-observable/Readme.md +116 -0
  38. data/vendor/components/indefinido-observable/build/build.js +14798 -0
  39. data/vendor/components/indefinido-observable/build/development.js +339 -0
  40. data/vendor/components/indefinido-observable/build/release.js +14937 -0
  41. data/vendor/components/indefinido-observable/build/test.js +339 -0
  42. data/vendor/components/indefinido-observable/component.json +7 -3
  43. data/vendor/components/indefinido-observable/components/chaijs-chai/component.json +46 -0
  44. data/vendor/components/indefinido-observable/components/chaijs-chai/index.js +1 -0
  45. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/assertion.js +132 -0
  46. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/core/assertions.js +1270 -0
  47. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/error.js +60 -0
  48. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/assert.js +1060 -0
  49. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/expect.js +12 -0
  50. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/should.js +76 -0
  51. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +94 -0
  52. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addMethod.js +37 -0
  53. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addProperty.js +40 -0
  54. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/eql.js +124 -0
  55. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/flag.js +32 -0
  56. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getActual.js +19 -0
  57. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +25 -0
  58. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getMessage.js +49 -0
  59. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getName.js +20 -0
  60. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getPathValue.js +102 -0
  61. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getProperties.js +35 -0
  62. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/index.js +108 -0
  63. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/inspect.js +316 -0
  64. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/objDisplay.js +48 -0
  65. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +51 -0
  66. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +54 -0
  67. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/test.js +26 -0
  68. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/transferFlags.js +44 -0
  69. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/type.js +45 -0
  70. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai.js +79 -0
  71. data/vendor/components/indefinido-observable/components/cjohansen-sinon/sinon.js +4290 -0
  72. data/vendor/components/indefinido-observable/components/component-jquery/component.json +14 -0
  73. data/vendor/components/indefinido-observable/components/component-jquery/index.js +9601 -0
  74. data/vendor/components/indefinido-observable/components/kapit-observe-shim/component.json +11 -0
  75. data/vendor/components/indefinido-observable/components/kapit-observe-utils/component.json +13 -0
  76. data/vendor/components/indefinido-observable/karma.conf.js +92 -0
  77. data/vendor/components/indefinido-observable/lib/observable.js +9 -19
  78. data/vendor/components/indefinido-observable/spec/legacy/observable_spec.js +126 -0
  79. data/vendor/components/indefinido-observable/spec/observable_spec.js +92 -0
  80. data/vendor/components/indefinido-observable/spec/spec_helper.js +8 -0
  81. data/vendor/components/indefinido-observable/spec/vendor/accessors_spec.js +63 -0
  82. data/vendor/components/indefinido-observable/src/lib/adapters/rivets.js.coffee +15 -0
  83. data/vendor/components/indefinido-observable/src/spec/legacy/observable_spec.coffee +132 -0
  84. data/vendor/components/indefinido-observable/src/spec/observable_spec.coffee +85 -0
  85. data/vendor/components/indefinido-observable/src/spec/spec_helper.coffee +5 -0
  86. data/vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee +59 -0
  87. data/vendor/components/indefinido-observable/vendor/spec/boot.js +104 -0
  88. data/vendor/components/indefinido-observable/vendor/spec/jasmine.js +2054 -0
  89. metadata +60 -8
  90. data/lib/assets/javascripts/aura/extensions/domain.js.coffee +0 -55
  91. data/lib/assets/javascripts/aura/extensions/stamps.js.coffee +0 -35
  92. data/lib/assets/javascripts/aura/extensions/widget/composable.js.coffee +0 -135
  93. data/lib/assets/javascripts/aura/extensions/widget/flowable.js.coffee +0 -65
  94. data/lib/assets/javascripts/widgets/attachable/main.js.coffee +0 -77
  95. /data/{lib/assets/javascripts/aura/extensions/stamps → vendor/assets/javascripts/stampit}/stampit.js +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 132a354f8488b0d4365d5af7d316b3233509dacf
4
- data.tar.gz: 2ee8c242cf523e31d55da0d664305e590c9d476c
3
+ metadata.gz: 611418ee7b73b1dc4be71d8f06e3b7fdf48788de
4
+ data.tar.gz: 2d576d36dc1ef08a1a242e69fb6725956eac477c
5
5
  SHA512:
6
- metadata.gz: 5967e853633eeacd0e3ae3a8cae10ebd48cb105098db100646519212bd50f3ee62306dd7caa71b7507db14c39bdfd925e608c7d021e632495370a26a3bb6f95a
7
- data.tar.gz: 00c3ee46d953cb469bfe64ed38ea9a937367a3a7d3f8a7905de02cfd4762c90101615a5779fea51315eae2c9c7a6126b93f51b5e8e32140d3a1584954ba40d4f
6
+ metadata.gz: f85d981b16fcb07b9b1320338d51b08e7e01ac4f012dee23b6d6cd9c1632e35851ee872a0a173fd9c7ebf0f5331537690069b5cc75263f94369134b66b3f6d24
7
+ data.tar.gz: 7c79f43fb08df869dfb18479368ee9d905747a78cd5bce5d137ba0ec4df7c44a631ab6ff0b8b93bf322cd47dcc46d512078051d5bf60243ebcab31d4f03a2377
data/README.md CHANGED
@@ -5,7 +5,7 @@ endë
5
5
  Summary
6
6
  -------
7
7
 
8
- Endë (core, middle) [![Gem Version](https://badge.fury.io/rb/ende.svg)](http://badge.fury.io/rb/ende)
8
+ Endë (core, middle)
9
9
 
10
10
  A modular web application rails gem. Using aurajs for architecture and indemma for resource management by default.
11
11
 
@@ -35,7 +35,6 @@ Components List
35
35
 
36
36
  _Detailed documentation is comming!_
37
37
 
38
- - Attachable
39
38
  - Authenticator
40
39
  - Content
41
40
  - Dialog
@@ -60,7 +59,7 @@ Extensions List
60
59
  - Devise
61
60
  - Rivets
62
61
  - Widget
63
- - Napable
62
+ - Napable
64
63
  - Lifecycleable
65
64
  - Eventable
66
65
  - Models
data/build/build.css ADDED
@@ -0,0 +1,111 @@
1
+ .overlay {
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ opacity: 1;
6
+ width: 100%;
7
+ height: 100%;
8
+ background: rgba(0,0,0,.75);
9
+ -webkit-transition: opacity 300ms;
10
+ -moz-transition: opacity 300ms;
11
+ transition: opacity 300ms;
12
+ z-index: 500;
13
+ }
14
+
15
+ .overlay.hide {
16
+ pointer-events: none;
17
+ opacity: 0;
18
+ }
19
+
20
+ #dialog {
21
+ position: fixed;
22
+ left: 50%;
23
+ top: 150px;
24
+ max-width: 600px;
25
+ min-width: 250px;
26
+ border: 1px solid #eee;
27
+ background: white;
28
+ z-index: 1000;
29
+ }
30
+
31
+ #dialog .content {
32
+ padding: 15px 20px;
33
+ }
34
+
35
+ #dialog h1 {
36
+ margin: 0 0 5px 0;
37
+ font-size: 16px;
38
+ font-weight: normal;
39
+ }
40
+
41
+ #dialog p {
42
+ margin: 0;
43
+ padding: 0;
44
+ font-size: .9em;
45
+ }
46
+
47
+ /* close */
48
+
49
+ #dialog .close {
50
+ position: absolute;
51
+ top: 3px;
52
+ right: 10px;
53
+ text-decoration: none;
54
+ color: #888;
55
+ font-size: 16px;
56
+ font-weight: bold;
57
+ display: none;
58
+ }
59
+
60
+ #dialog .close em {
61
+ display: none;
62
+ }
63
+
64
+ #dialog.closable .close {
65
+ display: block;
66
+ }
67
+
68
+ #dialog .close:hover {
69
+ color: black;
70
+ }
71
+
72
+ #dialog .close:active {
73
+ margin-top: 1px;
74
+ }
75
+
76
+ /* slide */
77
+
78
+ #dialog.slide {
79
+ -webkit-transition: opacity 300ms, top 300ms;
80
+ -moz-transition: opacity 300ms, top 300ms;
81
+ }
82
+
83
+ #dialog.slide.hide {
84
+ opacity: 0;
85
+ top: -500px;
86
+ }
87
+
88
+ /* fade */
89
+
90
+ #dialog.fade {
91
+ -webkit-transition: opacity 300ms;
92
+ -moz-transition: opacity 300ms;
93
+ }
94
+
95
+ #dialog.fade.hide {
96
+ opacity: 0;
97
+ }
98
+
99
+ /* scale */
100
+
101
+ #dialog.scale {
102
+ -webkit-transition: -webkit-transform 300ms;
103
+ -moz-transition: -moz-transform 300ms;
104
+ -webkit-transform: scale(1);
105
+ -moz-transform: scale(1);
106
+ }
107
+
108
+ #dialog.scale.hide {
109
+ -webkit-transform: scale(0);
110
+ -moz-transform: scale(0);
111
+ }
data/component.json CHANGED
@@ -21,6 +21,7 @@
21
21
  },
22
22
  "scripts": [
23
23
  "vendor/assets/javascripts/lennon/lennon.js",
24
+ "vendor/assets/javascripts/stampit/stampit.js",
24
25
  "vendor/assets/javascripts/spin/spin.js",
25
26
  "vendor/assets/javascripts/jquery/inview.js",
26
27
  "vendor/assets/javascripts/jquery/inputmask.js",
@@ -22,10 +22,9 @@ end
22
22
 
23
23
  'use strict'
24
24
 
25
-
26
25
  root = exports ? this
27
26
 
28
- define 'aura/extensions/models', <%= models_list.to_json %>, (resources...) ->
27
+ define 'aura/extensions/models', <%= models_list.to_json %>, (models...) ->
29
28
 
30
29
  # TODO better require api for indemma
31
30
  indemma = require 'indemma'
@@ -45,14 +44,10 @@ define 'aura/extensions/models', <%= models_list.to_json %>, (resources...) ->
45
44
  # inflector outside it
46
45
  require 'indefinido-indemma/vendor/owl/pluralize'
47
46
 
48
- name: 'resources'
49
-
50
- version: '0.1.2'
51
-
52
47
  # Extension definition
53
48
  initialize: (application) ->
54
- {core, sandbox} = application
55
-
49
+ core = application.core
50
+ sandbox = application.sandbox
56
51
  core.util.inflector =
57
52
  cssify: (sentence) -> sentence.replace /\//, '-'
58
53
  pluralize: indemma.model.pluralize
@@ -77,11 +72,7 @@ define 'aura/extensions/models', <%= models_list.to_json %>, (resources...) ->
77
72
 
78
73
  # TODO allow user to create custom definitions before resources
79
74
  # (models) get defined
80
- # new Aura(inflections: {measures: measures})
81
75
  core.util.inflector.define 'measures', 'measures'
82
76
 
83
77
  # Build all model definitions
84
- indemma.model.every = [] # TODO implement this on indemma
85
- core.util._.map resources, (definition) ->
86
- resource = indemma.model.call definition
87
- indemma.model.every.push resource
78
+ core.util._.map models, (model) -> indemma.model.call model
@@ -1,4 +1,4 @@
1
- 'use strict'
1
+ 'use strict';
2
2
 
3
3
  define 'aura/extensions/platform', ->
4
4
 
@@ -14,10 +14,4 @@ define 'aura/extensions/platform', ->
14
14
  application.core = Object.create application.core, descriptors
15
15
  application.sandbox = Object.create application.sandbox, descriptors
16
16
 
17
- # TODO copy other properties to the main application
18
-
19
-
20
- # TODO detect aura version and warn for updates
21
- application.components = {}
22
- application.components.config = application.config
23
- application.components.addSource = application.registerWidgetsSource
17
+ # TODO copy other properties to the main application
@@ -185,12 +185,15 @@ define 'aura/extensions/rivets', ['aura/extensions/rivets/formatters'], (formatt
185
185
  rivets.binders.spell ||=
186
186
  publishes: true
187
187
  bind: (el) ->
188
- @options.publisher ||= (event) =>
188
+
189
+ @options.publisher ||= (event) =>
189
190
  value = Rivets.Util.getInputValue @el
190
191
 
191
192
  # TODO more controllable enter handling
192
193
  return if event.which == 13
193
194
 
195
+ value += String.fromCharCode event.which || event.keyCode || event.charCode
196
+
194
197
  for formatter in @formatters.slice(0).reverse()
195
198
  args = formatter.split /\s+/
196
199
  id = args.shift()
@@ -201,18 +204,26 @@ define 'aura/extensions/rivets', ['aura/extensions/rivets/formatters'], (formatt
201
204
  @view.config.adapter.publish @model, @keypath, value
202
205
  event.preventDefault()
203
206
 
204
- # TODO Rivets.Util.bindEvent el, 'keypress change', @options.publisher
205
- Rivets.Util.bindEvent el, 'keyup' , @options.publisher
206
- Rivets.Util.bindEvent el, 'change' , @publish
207
-
207
+ if window.jQuery?
208
+ # TODO Rivets.Util.bindEvent el, 'keypress change', @options.publisher
209
+ Rivets.Util.bindEvent el, 'keypress', @options.publisher
210
+ Rivets.Util.bindEvent el, 'change' , @publish
211
+ else
212
+ Rivets.Util.bindEvent el, 'keypress', @options.publisher
213
+ Rivets.Util.bindEvent el, 'change' , @publish
208
214
 
209
215
  unbind: (el) ->
210
216
 
211
- Rivets.Util.unbindEvent el, 'keyup' , @options.publisher
212
- Rivets.Util.unbindEvent el, 'change', @publish
217
+ if window.jQuery?
218
+ # TODO Rivets.Util.unbindEvent el, 'keypress change', @options.publisher
219
+ Rivets.Util.unbindEvent el, 'keypress', @options.publisher
220
+ Rivets.Util.unbindEvent el, 'change', @publish
221
+ else
222
+ # TODO Rivets.Util.unbindEvent el, 'change' , @options.publisher
223
+ Rivets.Util.unbindEvent el, 'keypress', @options.publisher
224
+ Rivets.Util.unbindEvent el, 'change', @publish
213
225
 
214
226
  routine: (el, value) ->
215
-
216
227
  if window.jQuery?
217
228
  el = jQuery el
218
229
 
@@ -258,8 +269,8 @@ define 'aura/extensions/rivets', ['aura/extensions/rivets/formatters'], (formatt
258
269
 
259
270
  original_bind.apply rivets, arguments
260
271
 
261
- extend application.sandbox, view: rivets
262
- extend application.core , view: rivets
272
+ extend application.sandbox,
273
+ view: rivets
263
274
 
264
275
  extend application.core.Widgets.Base.prototype,
265
276
  bind: (presentation, options) ->
@@ -136,33 +136,31 @@ define 'aura/extensions/states', ['states'], (states) ->
136
136
 
137
137
  get: -> state.current
138
138
 
139
- # TODO clearer startup sequence
140
- application.core.metabolize = (root) ->
141
- # If any initialized flow changed the application state
142
- # before the widgets initialization, store its state pass
143
- # through the default state and go back to the old state
144
- # created by the flows
145
- #
146
- # TODO initialize the first flow in flows extension
147
- current_state = application.state if application.state != 'initialization'
148
- application.startOptions.widgets ||= root
139
+ afterAppStart: (application) ->
140
+ # TODO Change the application to default state in flows extension
141
+ if (application.startOptions.widgets)
149
142
  application.state = "default"
143
+ else
144
+ application.core.metabolize = ->
145
+ # If any initialized flow changed the application state
146
+ # before the widgets initialization, store its state pass
147
+ # through the default state and go back to the old state
148
+ # created by the flows
149
+ #
150
+ # TODO initialize the first flow in flows extension
151
+ current_state = application.state if application.state != 'initialization'
152
+ application.state = "default"
153
+
154
+ startup = application.core.start.apply @, arguments
155
+
156
+ # TODO move to domain extension
157
+ # TODO let this code more legible
158
+ domain_flow = application.domain.default
159
+ domain_flow?.ready ||= injection.then((widgets...) ->
160
+ # TODO use es6-shim promises
161
+ $.Deferred().resolveWith domain_flow, widgets
162
+ ).done
150
163
 
151
- startup = application.core.start arguments...
152
-
153
- # TODO move to domain extension
154
- # TODO let this code more legible
155
- domain_flow = application.domain.default
156
- domain_flow?.ready ||= injection.then((widgets...) ->
157
- # TODO use es6-shim promises
158
- $.Deferred().resolveWith domain_flow, widgets
159
- ).done
160
-
161
- application.state = current_state if current_state?
162
-
163
- startup
164
-
164
+ application.state = current_state if current_state?
165
165
 
166
- afterAppStart: (application) ->
167
- # TODO Change the application to default state in flows extension
168
- application.state = "default" if application.startOptions.widgets
166
+ startup
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- define 'aura/extensions/widget/eventable', ['stampit', 'es6-map-shim'], (stampit) ->
3
+ define 'aura/extensions/widget/eventable', ['es6-map-shim'], ->
4
4
 
5
5
  extractor = /.*?\$(.*?)@(.*?)\+(.*?)/
6
6
 
@@ -24,39 +24,44 @@ define 'aura/extensions/widget/eventable', ['stampit', 'es6-map-shim'], (stampit
24
24
  event.preventDefault()
25
25
  false
26
26
 
27
- eventable = stampit
28
- # TODO implement rivets compatibility, instead of generic
29
- # binding events, alter html
30
- handles: (event_name, widget_event_name = event_name, selector = @$el) ->
31
- unless @name
32
- message = "Widget name must be provided in order to use handlers, but this.name is '#{@name}' \n"
33
- message += "Also you may have forgotten to set the type of your widget to 'Base'"
34
- throw new TypeError message
27
+ eventable =
28
+ # TODO pass this extensions to the identifiable extension
29
+ # TODO use widget.extend with the constructor property
30
+ constructor: (options) ->
31
+ matches = extractor.exec options._ref
32
+ @name = matches[1]
33
+ @identifier = options.identifier or options.resource or matches[2]
35
34
 
36
- context = @$el unless selector == @$el
35
+ eventable.super.constructor.call @, options
37
36
 
38
- event_name = translations.get(event_name) ? event_name
37
+ @sandbox.identifier = @identifier
39
38
 
40
- @sandbox.dom.find(selector, context).on event_name, create_handler(@, widget_event_name || event_name)
39
+ @
41
40
 
42
- before_initialize: ->
43
- matches = extractor.exec @options._ref
44
- @name = matches[1]
45
- @identifier = @options.identifier or @options.resource or matches[2]
46
- @sandbox.identifier = @identifier
47
41
 
48
42
  version: '0.1.0'
49
43
 
50
44
  initialize: (application) ->
51
- application.core.Widgets.Base.compose eventable
45
+ with_component = 'segmentio-extend'
46
+ extend = require with_component
52
47
 
53
- {core: {mediator}} = application
54
- application.sandbox.startListening = ->
55
- # TODO @listening = true
56
- mediator.on event.name, event.callback for event in @_events
48
+ Widgets = application.core.Widgets
57
49
 
58
- true
50
+ extend Widgets.Base.prototype,
51
+ # TODO implement rivets compatibility, instead of generic
52
+ # binding events, alter html
53
+ handles: (event_name, widget_event_name = event_name, selector = @$el) ->
54
+ unless @name
55
+ message = "Widget name must be provided in order to use handlers, but this.name is '#{@name}' \n"
56
+ message = "Also you may have forgotten to set the type of your widget to 'Base'"
57
+ throw message
59
58
 
59
+ context = @$el unless selector == @$el
60
60
 
61
+ event_name = translations.get(event_name) ? event_name
61
62
 
63
+ @sandbox.dom.find(selector, context).on event_name, create_handler(@, widget_event_name || event_name)
62
64
 
65
+ # TODO replace Base.extend inheritance to stampit composition
66
+ Widgets.Base = Widgets.Base.extend eventable
67
+ eventable.super = Widgets.Base.__super__
@@ -6,12 +6,8 @@ define 'aura/extensions/widget/lifecycleable', ->
6
6
  with_component = 'jquery'
7
7
  jQuery = require with_component
8
8
 
9
- with_component = 'stampit/stampit'
10
- stampit = require with_component
11
-
12
9
  core = null
13
10
 
14
- # TODO transform into a composable
15
11
  lifecycleable =
16
12
  injection: (definition) ->
17
13
  options = definition.options
@@ -54,7 +50,7 @@ define 'aura/extensions/widget/lifecycleable', ->
54
50
  options.require.packages.push name: options.ref, location: widgetsPath + "/" + widgetName
55
51
  options.name = widgetName
56
52
 
57
- unless options.el?
53
+ unless options.el
58
54
  options.el = jQuery '<div class="widget"></div>'
59
55
  @root.append options.el
60
56
 
@@ -62,27 +58,24 @@ define 'aura/extensions/widget/lifecycleable', ->
62
58
 
63
59
  definition
64
60
 
65
- recyclable = stampit(
66
- inject: (name, options) ->
67
- core.inject name, options
68
-
69
- injection: -> lifecycleable.injection arguments...
61
+ recyclable =
62
+ constructor: (options) ->
70
63
 
71
- before_initialize: ->
72
64
  # TODO only listen to this specific sandbox stop
73
- # TODO stop listening when sandbox starts or stops
74
- @sandbox.on 'aura.sandbox.stop', (sandbox) ->
65
+ @sandbox.on 'aura.sandbox.stop', (sandbox) =>
75
66
  @stopped() if @sandbox.ref == sandbox.ref
76
- , @
77
67
 
78
- @sandbox.on 'aura.sandbox.start', (sandbox) ->
68
+ @sandbox.on 'aura.sandbox.start', (sandbox) =>
79
69
  @started() if @sandbox.ref == sandbox.ref
80
- , @
81
70
 
82
- initialized: ->
83
- # TODO think how to access parent widget in children ones
84
- @sandbox._widget ||= @
71
+ recyclable.super.constructor.call @, options
72
+
73
+ @initialized()
74
+
75
+ inject: (name, options) ->
76
+ core.inject name, options
85
77
 
78
+ initialized: ->
86
79
  @sandbox.emit "#{@name}.#{@identifier}.initialized", @
87
80
 
88
81
  started: ->
@@ -92,8 +85,6 @@ define 'aura/extensions/widget/lifecycleable', ->
92
85
  stopped: ->
93
86
  @$el.remove()
94
87
 
95
- ).enclose -> @initialized()
96
-
97
88
  (application) ->
98
89
 
99
90
  version: '0.2.0'
@@ -109,19 +100,12 @@ define 'aura/extensions/widget/lifecycleable', ->
109
100
  lifecycleable.sources = application.config.widgets.sources
110
101
  lifecycleable.find = core.dom.find
111
102
 
112
- Object.defineProperty lifecycleable, 'root',
113
- get: ->
114
- root = core.dom.find app.startOptions.widgets
115
- throw new TypeError "No root node found for selector '#{app.startOptions.widgets}'." unless root.length != 0
116
-
117
- # TODO Cache and override root when found
118
- # TODO check how this will integrate with mocha specs
119
- # Object.defineProperty lifecycleable, 'root', value: root
120
-
121
- root
122
-
123
- configurable: true
103
+ # TODO Keep searching for root until found, and only throw
104
+ # exception if someone tries to initialize widgets in root
105
+ # without a valid root selector
106
+ lifecycleable.root = core.dom.find app.startOptions.widgets || 'body'
124
107
 
108
+ throw new TypeError "No root node found for selector '#{app.startOptions.widgets}'." unless lifecycleable.root.length != 0
125
109
 
126
110
  lifecycleable.decamelize = core.util.decamelize
127
111
  lifecycleable.capitalize = core.util.capitalize
@@ -157,4 +141,7 @@ define 'aura/extensions/widget/lifecycleable', ->
157
141
  params[2] = @ if params.length < 3
158
142
  core.inject params...
159
143
 
160
- core.Widgets.Base.compose recyclable
144
+ # Add support for element removal after stoping widget
145
+ # TODO replace Base.extend inheritance to stampit composition
146
+ core.Widgets.Base = core.Widgets.Base.extend recyclable
147
+ recyclable.super = core.Widgets.Base.__super__
@@ -1,29 +1,33 @@
1
- 'use strict'
1
+ define 'aura/extensions/widget/napable', ->
2
2
 
3
- define 'aura/extensions/widget/napable', ['stampit/stampit'], (stampit) ->
3
+ 'use strict'
4
4
 
5
- # TODO think about adding rivets bindings to the element
6
- napable = stampit
7
- tired: ->
8
- @sandbox.on "#{@name}.#{@identifier}.sleep", @sleep, @
9
- @sandbox.on "#{@name}.#{@identifier}.wake" , @wake , @
10
- @
5
+ napable =
6
+ bind: ->
7
+ @sandbox.on "#{@name}.#{@identifier}.sleep", napable.sleep, @
8
+ @sandbox.on "#{@name}.#{@identifier}.wake" , napable.wake , @
11
9
  sleep: ->
12
10
  @$el.addClass 'asleep'
13
11
  @$el.removeClass 'awake'
14
12
  wake: ->
15
13
  @$el.addClass 'awake'
16
14
  @$el.removeClass 'asleep'
17
- ,
18
- naping: false
19
- , -> @tired()
15
+
16
+ napable_extensions =
17
+ constructor: ->
18
+ napable_extensions["super"].constructor.apply @, arguments
19
+ napable.bind.call @
20
20
 
21
21
  # The purpose of this extension is allow parent widget to save
22
22
  # memory by sending a sleep command to the child widgets
23
23
  (application) ->
24
24
 
25
- version: '0.1.2'
25
+ version: '0.1.0'
26
26
 
27
27
  initialize: (application) ->
28
28
  {core} = application
29
- core.Widgets.Base.compose napable
29
+
30
+ # Add support for element removal after stoping widget
31
+ # TODO replace Base.extend inheritance to stampit composition
32
+ core.Widgets.Base = core.Widgets.Base.extend napable_extensions
33
+ napable_extensions.super = core.Widgets.Base.__super__
@@ -26,8 +26,6 @@ define 'modernizr' , ['config/load_components'], ->
26
26
  require 'modernizr'
27
27
  window.Modernizr
28
28
 
29
- define 'rivets', ['config/load_components'], -> require 'rivets'
30
-
31
29
  # TODO define 'underscore', ['config/load_components'], -> require 'lodash'
32
30
 
33
31
  # TODO figure out how to use rjs optmizer to include component builds
@@ -123,8 +121,8 @@ define 'config/load_components', ['application_components'], ->
123
121
  using = loader.discover params...
124
122
 
125
123
  try
126
- # TODO rename mod to module
127
- mod = loader.loaders.discovered.apply @, params
124
+
125
+ module = loader.loaders.discovered.apply @, params
128
126
 
129
127
  catch e
130
128
  if e.require
@@ -134,15 +132,15 @@ define 'config/load_components', ['application_components'], ->
134
132
 
135
133
  # Since it failed to load with component, try to load with requirejs
136
134
  loader.activate 'requirejs'
137
- unless mod
138
- mod = loader.loaders.discovered.apply @, params
135
+ unless module
136
+ module = loader.loaders.discovered.apply @, params
139
137
  else
140
138
  throw e
141
139
 
142
140
  # Always let requirejs active by default
143
141
  loader.activate 'requirejs'
144
142
 
145
- mod
143
+ module
146
144
 
147
145
  loader.shim()
148
146
  loader.initialize()
@@ -165,8 +165,7 @@ define ->
165
165
  extract_options: ->
166
166
  options = _.omit @options, 'el', 'ref', '_ref', 'name', 'require', 'baseUrl', 'theme', 'resource'
167
167
 
168
- # TODO merge default options in prototype
169
- dynamic_options = _.omit options, Object.keys(@__proto__.options)
168
+ dynamic_options = _.omit options, Object.keys(@constructor.__super__.options)
170
169
 
171
170
  keys = Object.keys dynamic_options
172
171
  throw new TypeError "Too many keys on options object! #{keys.join(', ')}" unless keys.length == 1
@@ -1,13 +1,13 @@
1
1
  'use strict'
2
+ observable = require('indefinido-observable').mixin
2
3
 
3
- define ->
4
+ define (model) ->
4
5
 
5
6
  (items, luna) ->
6
7
 
7
8
  resource = items[0].resource
8
9
 
9
- # TODO create view_model
10
- searcher:
10
+ searcher: observable
11
11
  query: ''
12
12
  search: (event, models) ->
13
13
 
@@ -22,7 +22,8 @@ define ->
22
22
 
23
23
  false
24
24
 
25
- list: Object.create null,
25
+ # TODO create view_model
26
+ list: observable Object.create null,
26
27
  resource:
27
28
  set: (resource) -> null
28
29
  get: -> resource
@@ -114,7 +114,7 @@ define(function () {
114
114
  update_user: function (user) {
115
115
  user.email && olark('api.visitor.updateEmailAddress', {emailAddress: user.email});
116
116
  user.name && olark('api.visitor.updateFullName' , {fullName: user.name});
117
- user.phone.toString() && olark('api.visitor.updatePhoneNumber' , {phoneNumber: user.phone.toString()});
117
+ user.phone && olark('api.visitor.updatePhoneNumber' , {phoneNumber: user.phone});
118
118
  // TODO rename user._id to user.id
119
119
  user._id && olark('api.visitor.updateCustomFields', {id: user._id});
120
120
  }