ende 0.4.16 → 0.4.17

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: cdb0e99ce35297e3963645d52bd4c9bde6f28bb8
4
- data.tar.gz: 2b092352c25dea75166f48dddaaf7c029ccc1385
3
+ metadata.gz: 57911b65c0263d7e7a35c38e102979e48fea85d3
4
+ data.tar.gz: 0502ed60282bcd93ca5dd4498a8dbd2563a104f8
5
5
  SHA512:
6
- metadata.gz: 15026887ecce38a682ba33527bb436718e92930cb5aeca86cbc327dab61597af00efec271e0b4d613b1f966cc1a757e4b2dab615f6f000cae362fcc3b0db01a6
7
- data.tar.gz: 0f1990ca14333df8b9ae5170fb64bd009baf3219e5f3215173e425da81a81de1e28f0b9961daf492a682cc4db621bded98d07878d8d6a077919e3df492789037
6
+ metadata.gz: b20043f29efda05c3004d87d5a19407349143879f7fedb8ae3fbf6e58c1ae569819df163560a98886098246730210aef4607f40454a3849d1531263643f45f70
7
+ data.tar.gz: f69f2597087fa67c2f250ef3a9c492a1c748aa561b79a3cbedc7dc0ff48be50f7d460a13107d67dc371edf7af2edef5bedc3156ec00324800d2592c839399a5c
data/README.md CHANGED
@@ -35,6 +35,7 @@ Components List
35
35
 
36
36
  _Detailed documentation is comming!_
37
37
 
38
+ - Attachable
38
39
  - Authenticator
39
40
  - Content
40
41
  - Dialog
@@ -59,7 +60,7 @@ Extensions List
59
60
  - Devise
60
61
  - Rivets
61
62
  - Widget
62
- - Napable
63
+ - Napable
63
64
  - Lifecycleable
64
65
  - Eventable
65
66
  - Models
@@ -0,0 +1,53 @@
1
+ 'use strict'
2
+
3
+ define 'aura/extensions/domain', ->
4
+
5
+ # The purpose of this extension is have a business domain practice
6
+ # integrated with the core application functionality
7
+
8
+ version: '0.1.0'
9
+
10
+ initialize: (application) ->
11
+ {core: {mediator}} = application
12
+ stampit = require 'stampit/stampit'
13
+
14
+ eventable = stampit
15
+ on : mediator.on
16
+ off : mediator.off
17
+ once : mediator.once
18
+ many : mediator.many
19
+ emit : mediator.emit
20
+ unlisten: mediator.removeAllListeners
21
+
22
+ domainable = stampit()
23
+
24
+ # application.use('extensions/models').use 'extensions/widget/flows'
25
+ # TODO detect if flows extension and models extension have already been loaded
26
+
27
+ # TODO require domain commands
28
+ application.domain ||= eventable()
29
+
30
+ afterAppStart: (application) ->
31
+ {core: {resourceable: {every: resourceables}, Widgets: {Flow}}} = application
32
+
33
+ extensions = {}
34
+ for resourceable in resourceables
35
+ resource = resourceable.resource.toString()
36
+
37
+ namespaces = resource.split '/'
38
+ method = namespaces.pop() + 'able'
39
+
40
+ # Create namespaces
41
+ node = extensions
42
+ for namespace in namespaces
43
+ node[namespace] ||= {}
44
+ node = node[namespace]
45
+
46
+ node[method] = resourceable
47
+
48
+ Flow.composition.methods extensions
49
+
50
+
51
+
52
+
53
+
@@ -25,7 +25,7 @@ end
25
25
 
26
26
  root = exports ? this
27
27
 
28
- define 'aura/extensions/models', <%= models_list.to_json %>, (models...) ->
28
+ define 'aura/extensions/models', <%= models_list.to_json %>, (resources...) ->
29
29
 
30
30
  # TODO better require api for indemma
31
31
  indemma = require 'indemma'
@@ -45,10 +45,14 @@ define 'aura/extensions/models', <%= models_list.to_json %>, (models...) ->
45
45
  # inflector outside it
46
46
  require 'indefinido-indemma/vendor/owl/pluralize'
47
47
 
48
+ name: 'resources'
49
+
50
+ version: '0.1.2'
51
+
48
52
  # Extension definition
49
53
  initialize: (application) ->
50
- core = application.core
51
- sandbox = application.sandbox
54
+ {core, sandbox} = application
55
+
52
56
  core.util.inflector =
53
57
  cssify: (sentence) -> sentence.replace /\//, '-'
54
58
  pluralize: indemma.model.pluralize
@@ -73,7 +77,11 @@ define 'aura/extensions/models', <%= models_list.to_json %>, (models...) ->
73
77
 
74
78
  # TODO allow user to create custom definitions before resources
75
79
  # (models) get defined
80
+ # new Aura(inflections: {measures: measures})
76
81
  core.util.inflector.define 'measures', 'measures'
77
82
 
78
83
  # Build all model definitions
79
- core.util._.map models, (model) -> indemma.model.call model
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
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ 'use strict'
2
2
 
3
3
  define 'aura/extensions/platform', ->
4
4
 
@@ -14,4 +14,10 @@ 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
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
@@ -149,9 +149,10 @@ define 'aura/extensions/states', ['states'], (states) ->
149
149
  #
150
150
  # TODO initialize the first flow in flows extension
151
151
  current_state = application.state if application.state != 'initialization'
152
+ application.startOptions.widgets = arguments[0]
152
153
  application.state = "default"
153
154
 
154
- startup = application.core.start.apply @, arguments
155
+ startup = application.core.start arguments...
155
156
 
156
157
  # TODO move to domain extension
157
158
  # TODO let this code more legible
@@ -0,0 +1,136 @@
1
+ 'use strict';
2
+
3
+ define 'aura/extensions/widget/composable', ->
4
+ stampit = extend = null
5
+
6
+ advisorable = (advisor) ->
7
+ # TODO merge advices in the composition chain
8
+ advice_names = ['before', 'after', 'around']
9
+
10
+ extract_advices = (object) ->
11
+ found = []
12
+ for key of object when key.indexOf('_') isnt -1
13
+ [name, adviced] = key.split '_'
14
+
15
+ if advice_names.indexOf(name) != -1
16
+ callbacks = if object[key].length then object[key] else [object[key]]
17
+
18
+ delete object[key]
19
+
20
+ found.push
21
+ key: key
22
+ name: name
23
+ adviced: adviced
24
+ callbacks: callbacks
25
+
26
+ found
27
+
28
+ advisor.advice = (widget) ->
29
+
30
+ advices = extract_advices widget
31
+
32
+ for advice in advices
33
+
34
+ # in order to preserve declaration order, we must reverse the callbacks order
35
+ advice.callbacks.reverse() if advice.name == 'before'
36
+
37
+ # Advice with all callbacks
38
+ widget[advice.name] advice.adviced, callback for callback in advice.callbacks
39
+
40
+ widget
41
+
42
+ advisor.advisable = (factory) ->
43
+ original = factory.compose
44
+
45
+ stampit.mixIn factory,
46
+ compose: (stamps...) ->
47
+ {fixed: {methods: composition_methods}} = @composition
48
+ advices = extract_advices composition_methods
49
+
50
+ for stamp in stamps
51
+ {fixed: {methods: stamp_methods}} = stamp
52
+ advices = advices.concat extract_advices stamp_methods
53
+
54
+ adviced_stamp = {}
55
+ for advice in advices
56
+ adviced_stamp[advice.key] ||= []
57
+ adviced_stamp[advice.key] = adviced_stamp[advice.key].concat advice.callbacks
58
+
59
+ # Create a ultimate stamp with all advices arrays or functions merged
60
+ # TODO do not store advices definitions in the prototype chain
61
+ stamps.push stampit adviced_stamp
62
+
63
+ original.apply factory, stamps
64
+
65
+ advice: advisor.advice
66
+
67
+ advisor
68
+
69
+ composerable = (compositor) ->
70
+ compositor.composable = (methods, state, enclose) ->
71
+ factory = (options) ->
72
+
73
+ # Inherit defaults from widget
74
+ options = _.defaults options, factory.composition.fixed.methods.options
75
+
76
+ # Composition only will compose methods and state!
77
+ instance = factory.composition options: options
78
+ enclose.call instance, options
79
+
80
+ # TODO check if it is needed to inherit compositions
81
+ # if methods.composition
82
+ # composition = methods.composition
83
+ # delete methods.composition
84
+ # composition = stampit.compose composition, stampit methods, state
85
+ # else
86
+ # composition = stampit methods, state
87
+
88
+ stampit.mixIn factory,
89
+ composition: stampit methods, state
90
+ # Suport an extension with multiple compositions
91
+ compose: -> @composition = stampit.compose @composition, arguments...
92
+
93
+ extend: ->
94
+ `var methods, state`
95
+ {fixed} = @composition
96
+ initializers = [enclose]
97
+ methods = {}
98
+ state = {}
99
+
100
+ for definition in arguments
101
+ {methods: definition_methods, state: definition_state} = definition
102
+
103
+ methods = extend methods, fixed.methods, definition_methods or definition
104
+ state = extend state , fixed.state , definition_state
105
+
106
+ initializers.push fixed.enclose if fixed.enclose
107
+ initializers.push definition.enclose if definition.enclose
108
+
109
+ enclosed = (properties) ->
110
+ initializers.forEach (initializer) => initializer.call @, properties
111
+ @
112
+
113
+ compositor.composable methods, state, enclosed or enclose
114
+
115
+ compositor
116
+
117
+ version: '0.1.1'
118
+
119
+ initialize: (application) ->
120
+ stampit = require 'stampit/stampit'
121
+ advisable = require 'advisable'
122
+
123
+ {core: {Widgets, util: {extend}}} = application
124
+
125
+ Widgets = composerable advisorable Widgets
126
+
127
+ # THINK how to at the same time respect aura ways of instantiating
128
+ # widgets and preserve widget logic composability
129
+ Widgets.Default = Widgets.Base
130
+ delete Widgets.Default.extend
131
+
132
+ Widgets.Base = Widgets.advisable Widgets.composable advisable(Widgets.Default.prototype), null, (options) ->
133
+ Object.defineProperty @, 'constructor', value: Widgets.Default, enumerable: false, configurable: false, writable: false
134
+ Widgets.Default.call Widgets.advice(@), options
135
+
136
+
@@ -24,44 +24,43 @@ define 'aura/extensions/widget/eventable', ['es6-map-shim'], ->
24
24
  event.preventDefault()
25
25
  false
26
26
 
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]
27
+ # TODO pass this extensions to the identifiable extension
28
+ with_component = 'stampit/stampit'
29
+ stampit = require with_component
34
30
 
35
- eventable.super.constructor.call @, options
31
+ eventable = stampit
32
+ # TODO implement rivets compatibility, instead of generic
33
+ # binding events, alter html
34
+ handles: (event_name, widget_event_name = event_name, selector = @$el) ->
35
+ unless @name
36
+ message = "Widget name must be provided in order to use handlers, but this.name is '#{@name}' \n"
37
+ message += "Also you may have forgotten to set the type of your widget to 'Base'"
38
+ throw new TypeError message
36
39
 
37
- @sandbox.identifier = @identifier
40
+ context = @$el unless selector == @$el
38
41
 
39
- @
42
+ event_name = translations.get(event_name) ? event_name
40
43
 
44
+ @sandbox.dom.find(selector, context).on event_name, create_handler(@, widget_event_name || event_name)
45
+
46
+ before_initialize: ->
47
+ matches = extractor.exec @options._ref
48
+ @name = matches[1]
49
+ @identifier = @options.identifier or @options.resource or matches[2]
50
+ @sandbox.identifier = @identifier
41
51
 
42
52
  version: '0.1.0'
43
53
 
44
54
  initialize: (application) ->
45
- with_component = 'segmentio-extend'
46
- extend = require with_component
55
+ application.core.Widgets.Base.compose eventable
47
56
 
48
- Widgets = application.core.Widgets
57
+ {core: {mediator}} = application
58
+ application.sandbox.startListening = ->
59
+ # TODO @listening = true
60
+ mediator.on event.name, event.callback for event in @_events
49
61
 
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
62
+ true
58
63
 
59
- context = @$el unless selector == @$el
60
64
 
61
- event_name = translations.get(event_name) ? event_name
62
65
 
63
- @sandbox.dom.find(selector, context).on event_name, create_handler(@, widget_event_name || event_name)
64
66
 
65
- # TODO replace Base.extend inheritance to stampit composition
66
- Widgets.Base = Widgets.Base.extend eventable
67
- eventable.super = Widgets.Base.__super__
@@ -0,0 +1,65 @@
1
+ 'use strict'
2
+
3
+ define 'aura/extensions/widget/flowable', ->
4
+
5
+ # The purpose of this extension is have a formalized widget type to
6
+ # put domain comunication logic between other widgets
7
+ (application) ->
8
+
9
+ instantiation =
10
+ composite_with: ->
11
+
12
+ stampit = require 'stampit/stampit'
13
+
14
+ # TODO Move each composable to its file
15
+ eventable = stampit().enclose ->
16
+ @on = @sandbox.on
17
+ @off = @sandbox.off
18
+ @once = @sandbox.once
19
+ @many = @sandbox.many
20
+ @emit = @sandbox.emit
21
+ @unlisten = @sandbox.removeAllListeners
22
+
23
+ @
24
+
25
+ filterable = stampit()
26
+
27
+ routeable = stampit()
28
+
29
+ stateable = stampit(transit: (state) -> application.state = state).enclose ->
30
+ Object.defineProperty @, 'state',
31
+ set: @transit
32
+ get: -> application.state
33
+ configurable: false
34
+
35
+ @stateless()
36
+
37
+ elementless = stampit ->
38
+ marker = " #{@name}.#{@identifier} flow "
39
+ node = document.createComment marker
40
+ @$el.replaceWith node
41
+ @$el = $ node
42
+
43
+ stampit.compose filterable, routeable, eventable, stateable, elementless
44
+
45
+ create_widget_type: (flowable, application) ->
46
+ {core: {Widgets}} = application
47
+
48
+ Widgets.Flow = Widgets.composable Widgets.Default.prototype, null, (options) -> Widgets.Default.call @, options
49
+ Widgets.Flow.compose flowable
50
+
51
+ version: '0.1.0'
52
+
53
+ initialize: (application) ->
54
+ flowable = instantiation.composite_with application
55
+ instantiation.create_widget_type flowable, application
56
+
57
+ afterAppStart: (application) ->
58
+ application.components.addSource 'flow', 'flows'
59
+
60
+
61
+
62
+
63
+
64
+
65
+
@@ -6,8 +6,12 @@ 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
+
9
12
  core = null
10
13
 
14
+ # TODO transform into a composable
11
15
  lifecycleable =
12
16
  injection: (definition) ->
13
17
  options = definition.options
@@ -50,7 +54,7 @@ define 'aura/extensions/widget/lifecycleable', ->
50
54
  options.require.packages.push name: options.ref, location: widgetsPath + "/" + widgetName
51
55
  options.name = widgetName
52
56
 
53
- unless options.el
57
+ unless options.el?
54
58
  options.el = jQuery '<div class="widget"></div>'
55
59
  @root.append options.el
56
60
 
@@ -58,22 +62,21 @@ define 'aura/extensions/widget/lifecycleable', ->
58
62
 
59
63
  definition
60
64
 
61
- recyclable =
62
- constructor: (options) ->
65
+ recyclable = stampit(
66
+ inject: (name, options) ->
67
+ core.inject name, options
68
+
69
+ injection: -> lifecycleable.injection arguments...
63
70
 
71
+ before_initialize: ->
64
72
  # TODO only listen to this specific sandbox stop
65
- @sandbox.on 'aura.sandbox.stop', (sandbox) =>
73
+ @sandbox.on 'aura.sandbox.stop', (sandbox) ->
66
74
  @stopped() if @sandbox.ref == sandbox.ref
75
+ , @
67
76
 
68
- @sandbox.on 'aura.sandbox.start', (sandbox) =>
77
+ @sandbox.on 'aura.sandbox.start', (sandbox) ->
69
78
  @started() if @sandbox.ref == sandbox.ref
70
-
71
- recyclable.super.constructor.call @, options
72
-
73
- @initialized()
74
-
75
- inject: (name, options) ->
76
- core.inject name, options
79
+ , @
77
80
 
78
81
  initialized: ->
79
82
  # TODO think how to access parent widget in children ones
@@ -88,6 +91,7 @@ define 'aura/extensions/widget/lifecycleable', ->
88
91
  stopped: ->
89
92
  @$el.remove()
90
93
 
94
+ ).enclose -> @initialized()
91
95
 
92
96
  (application) ->
93
97
 
@@ -104,12 +108,18 @@ define 'aura/extensions/widget/lifecycleable', ->
104
108
  lifecycleable.sources = application.config.widgets.sources
105
109
  lifecycleable.find = core.dom.find
106
110
 
107
- # TODO Keep searching for root until found, and only throw
108
- # exception if someone tries to initialize widgets in root
109
- # without a valid root selector
110
- lifecycleable.root = core.dom.find app.startOptions.widgets || 'body'
111
+ Object.defineProperty lifecycleable, 'root',
112
+ get: ->
113
+ root = core.dom.find app.startOptions.widgets
114
+ throw new TypeError "No root node found for selector '#{app.startOptions.widgets}'." unless root.length != 0
115
+
116
+ # Cache and override root when found
117
+ Object.defineProperty lifecycleable, 'root', value: root
118
+
119
+ root
120
+
121
+ configurable: true
111
122
 
112
- throw new TypeError "No root node found for selector '#{app.startOptions.widgets}'." unless lifecycleable.root.length != 0
113
123
 
114
124
  lifecycleable.decamelize = core.util.decamelize
115
125
  lifecycleable.capitalize = core.util.capitalize
@@ -145,7 +155,4 @@ define 'aura/extensions/widget/lifecycleable', ->
145
155
  params[2] = @ if params.length < 3
146
156
  core.inject params...
147
157
 
148
- # Add support for element removal after stoping widget
149
- # TODO replace Base.extend inheritance to stampit composition
150
- core.Widgets.Base = core.Widgets.Base.extend recyclable
151
- recyclable.super = core.Widgets.Base.__super__
158
+ core.Widgets.Base.compose recyclable
@@ -2,7 +2,8 @@ define 'aura/extensions/widget/napable', ->
2
2
 
3
3
  'use strict'
4
4
 
5
- napable =
5
+ # TODO think about adding rivets bindings to the element
6
+ napable = stampit
6
7
  bind: ->
7
8
  @sandbox.on "#{@name}.#{@identifier}.sleep", napable.sleep, @
8
9
  @sandbox.on "#{@name}.#{@identifier}.wake" , napable.wake , @
@@ -12,22 +13,18 @@ define 'aura/extensions/widget/napable', ->
12
13
  wake: ->
13
14
  @$el.addClass 'awake'
14
15
  @$el.removeClass 'asleep'
15
-
16
- napable_extensions =
17
- constructor: ->
18
- napable_extensions["super"].constructor.apply @, arguments
19
- napable.bind.call @
16
+ ,
17
+ naping: false
18
+ , ->
19
+ napable_extensions["super"].constructor.apply @, arguments
20
+ napable.bind.call @
20
21
 
21
22
  # The purpose of this extension is allow parent widget to save
22
23
  # memory by sending a sleep command to the child widgets
23
24
  (application) ->
24
25
 
25
- version: '0.1.0'
26
+ version: '0.1.1'
26
27
 
27
28
  initialize: (application) ->
28
29
  {core} = application
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__
30
+ core.Widgets.Base.compose napable
@@ -121,8 +121,8 @@ define 'config/load_components', ['application_components'], ->
121
121
  using = loader.discover params...
122
122
 
123
123
  try
124
-
125
- module = loader.loaders.discovered.apply @, params
124
+ # TODO rename mod to module
125
+ mod = loader.loaders.discovered.apply @, params
126
126
 
127
127
  catch e
128
128
  if e.require
@@ -132,15 +132,15 @@ define 'config/load_components', ['application_components'], ->
132
132
 
133
133
  # Since it failed to load with component, try to load with requirejs
134
134
  loader.activate 'requirejs'
135
- unless module
136
- module = loader.loaders.discovered.apply @, params
135
+ unless mod
136
+ mod = loader.loaders.discovered.apply @, params
137
137
  else
138
138
  throw e
139
139
 
140
140
  # Always let requirejs active by default
141
141
  loader.activate 'requirejs'
142
142
 
143
- module
143
+ mod
144
144
 
145
145
  loader.shim()
146
146
  loader.initialize()
@@ -0,0 +1,77 @@
1
+ define ->
2
+
3
+ # TODO create diferent type for non-ui composable widgets
4
+ # TODO think about how to make this widget dependent on eventable extension
5
+ # TODO move this widtet to an extension when element is stored in the sandbox
6
+ type: 'Base'
7
+
8
+ version: '0.1.0'
9
+
10
+ # TODO options: {state: 'reset' # Will preserve initial widget state }
11
+
12
+ initialize: (options) ->
13
+
14
+ @sandbox._attachments = []
15
+
16
+ @$el.addClass "widget #{@name} composing"
17
+
18
+ # TODO think how to extend widgets as a way of knowing all children have started
19
+ @compose_when_parent()
20
+
21
+ # TODO think how to extend widgets as a way of knowing all children have started
22
+ compose_when_parent: ->
23
+ @interval = setInterval =>
24
+ if @sandbox._parent?
25
+ @compose @sandbox._parent._widget
26
+ clearInterval @interval
27
+ , 800
28
+
29
+ # Create a widget type to replace @$el for a html comment
30
+ compose: (parent) ->
31
+ @parent = parent
32
+ parent_namespace = parent.name + '.' + parent.identifier
33
+
34
+ # TODO move to elementless widgets
35
+ @transform_into_elementless()
36
+
37
+ @sandbox.on "#{parent_namespace}.reattach", @reattach, @
38
+ @sandbox.on "#{parent_namespace}.detach" , @detach , @
39
+ @sandbox.on "#{parent_namespace}.attach" , @attach , @
40
+
41
+ transform_into_elementless: ->
42
+ serializable_options = _.omit @options, '$el', 'el', 'ref', '_ref', 'require', 'baseUrl'
43
+
44
+ marker = " #{@name}.#{@identifier} for #{@parent.name}.#{parent.identifier}"
45
+ marker += " with #{JSON.stringify serializable_options} "
46
+ node = document.createComment marker
47
+ @$el.replaceWith node
48
+
49
+ @$el = $ node
50
+
51
+ reattach: (selector) ->
52
+ @detach()
53
+ @attach selector
54
+
55
+ detach: ->
56
+ @sandbox.stopListening()
57
+ # TODO Support multiple deatachments events storage
58
+ current_events = @sandbox._events
59
+ @sandbox._events = @sandbox._attachments.shift() || []
60
+ @sandbox._attachments.push current_events
61
+
62
+ # TODO unbind and store jquery handlers
63
+ # TODO store element position in the attachment
64
+ @parent.$el.detach()
65
+
66
+ attach: (selector) ->
67
+ element = @sandbox.dom.find selector
68
+ @sandbox.logger.error "attach: No element found for #{selector} for attachment" unless element.length
69
+
70
+ # TODO Support multiple deatachments events storage
71
+ @sandbox._attachments.push @sandbox._events
72
+ @sandbox._events = @sandbox._attachments.shift() || []
73
+ @sandbox.startListening()
74
+
75
+ # TODO rebind jquery handlers
76
+ # TODO restore element position of the attachment
77
+ element.append @parent.$el
@@ -1,24 +1,22 @@
1
- define ->
1
+ 'use strict'
2
2
 
3
- 'use strict'
3
+ define
4
4
 
5
5
  type: 'Base'
6
6
 
7
7
  version: '0.1.2'
8
8
 
9
9
  initialize: (options) ->
10
- names = []
11
10
  {identifier} = options
11
+ @names = []
12
12
 
13
- # TODO access omit method throuhgh underscore
13
+ # TODO access omit method throuhgh sandbox
14
14
  widget_options = _.omit options, 'el', 'ref', '_ref', 'name', 'require', 'baseUrl', 'resource'
15
15
 
16
16
  # TODO remove jquery dependency
17
- for name, suboptions of widget_options when $.type(suboptions) is "object"
18
- names.push suboptions.name || name
19
- @add suboptions.name || name, suboptions
17
+ injections = @prepare_injections widget_options
20
18
 
21
- @$el.addClass ['tray', 'widget'].concat(names).join(' ')
19
+ @$el.addClass ['tray', 'widget'].concat(@names).join(' ')
22
20
 
23
21
  @identifier ||= identifier
24
22
 
@@ -27,13 +25,21 @@ define ->
27
25
  @identifier = identifier
28
26
  @$el.attr 'id', identifier
29
27
 
30
- @sandbox.start()
28
+ # TODO get defer through sandbox
29
+ _.defer =>
30
+ @sandbox.start injections
31
+
32
+ prepare_injections: (widget_options) ->
33
+ # TODO remove jquery dependency, and use type detection through sandbox
34
+ for name, suboptions of widget_options when $.type(suboptions) is "object"
35
+ @names.push suboptions.name || name
36
+
37
+ # TODO do not allow elements outside of the tray
38
+ # TODO remove jquery dependency, and use documentFragment to build widgets
39
+ # TODO allow widgets without elements
40
+ @$el.append suboptions.el = jQuery '<div class="widget"></div>'
31
41
 
32
- add: (name, options) ->
42
+ @injection
43
+ name: suboptions.name || name
44
+ options: suboptions
33
45
 
34
- # TODO add widgets as childrens of the tray widget sandbox
35
- # TODO remove jquery dependency, and use documentFragment to build widgets
36
- element = jQuery '<div class="widget"></div>'
37
- options.el = element
38
- @$el.append element
39
- @inject name, options
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- lazy_requires = ['observable', 'advisable']
3
+ lazy_require = 'advisable'
4
4
  define [
5
5
  './states/index',
6
6
  './presenters/default',
7
7
  'jquery.inview',
8
8
  'stampit/stampit',
9
- lazy_requires[0],
10
- lazy_requires[1]], (templates, presenter, inview, stampit, observable, advisable) ->
9
+ 'observable',
10
+ lazy_require], (templates, presenter, inview, stampit, observable, advisable) ->
11
11
 
12
12
  scopable = (widget) ->
13
13
  deferred = widget.sandbox.data.deferred()
@@ -1,11 +1,6 @@
1
1
  'use strict';
2
2
 
3
- window.domo = []
4
-
5
- # TODO define componentjs required packages, as requirejs packages
6
- observable = require('indefinido-observable').mixin
7
-
8
- define ['stampit/stampit'], (stampit) ->
3
+ define ['stampit/stampit', 'observable'], (stampit, observable) ->
9
4
 
10
5
  scopingable = stampit
11
6
  start: ->
@@ -42,7 +37,6 @@ define ['stampit/stampit'], (stampit) ->
42
37
  @
43
38
 
44
39
 
45
-
46
40
  scopable = stampit
47
41
  forward_scope_data: (scope_name, data) ->
48
42
  switch @scope['$' + scope_name].constructor
data/lib/ende/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ende
2
- VERSION = "0.4.16"
2
+ VERSION = "0.4.17"
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.4.16
4
+ version: 0.4.17
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-03-27 00:00:00.000000000 Z
11
+ date: 2014-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,6 +71,7 @@ files:
71
71
  - ende.gemspec
72
72
  - lib/assets/.gitkeep
73
73
  - lib/assets/javascripts/aura/extensions/devise.js.coffee
74
+ - lib/assets/javascripts/aura/extensions/domain.js.coffee
74
75
  - lib/assets/javascripts/aura/extensions/loader.js.coffee
75
76
  - lib/assets/javascripts/aura/extensions/mask.js.coffee
76
77
  - lib/assets/javascripts/aura/extensions/mediator.js
@@ -82,7 +83,9 @@ files:
82
83
  - lib/assets/javascripts/aura/extensions/routes.js.coffee
83
84
  - lib/assets/javascripts/aura/extensions/screening.js.coffee
84
85
  - lib/assets/javascripts/aura/extensions/states.js.coffee
86
+ - lib/assets/javascripts/aura/extensions/widget/composable.js.coffee
85
87
  - lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee
88
+ - lib/assets/javascripts/aura/extensions/widget/flowable.js.coffee
86
89
  - lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee
87
90
  - lib/assets/javascripts/aura/extensions/widget/napable.js.coffee
88
91
  - lib/assets/javascripts/aura/extensions/widget/presentable.js.coffee
@@ -93,6 +96,7 @@ files:
93
96
  - lib/assets/javascripts/config/load_components.js.coffee
94
97
  - lib/assets/javascripts/ende.js.coffee
95
98
  - lib/assets/javascripts/value_objects/phone.js.coffee
99
+ - lib/assets/javascripts/widgets/attachable/main.js.coffee
96
100
  - lib/assets/javascripts/widgets/authenticator/main.js.coffee
97
101
  - lib/assets/javascripts/widgets/authenticator/presenter.js.coffee
98
102
  - lib/assets/javascripts/widgets/authenticator/states/default.html