vendor/assets/javascripts/modularity.js.coffee in modularity-rails-0.6.0 vs vendor/assets/javascripts/modularity.js.coffee in modularity-rails-0.6.1

- old
+ new

@@ -17,18 +17,19 @@ return alert "Error in Module constructor: The given container ('#{container.selector}') is empty." unless container? and container.length > 0 return alert "Error in Module constructor: The given container ('#{container.selector}') has more than one element." unless container? and container.length == 1 if @mixins? - for mixin in @mixins + for mixin_data in @mixins # Attach all properties from mixin to the prototype. - for methodName, method of mixin - @[methodName] = method + for methodName, method of mixin_data.mixin + unless @[methodName] + @[methodName] = => method.call(@, mixin_data.params) # Call constructor function from mixin. - mixin.constructor.apply @, arguments + mixin_data.mixin.constructor.apply @, arguments # Checks whether the given condition is true. # Shows an alert with the given message if not. @assert: (condition, message) -> @@ -51,12 +52,13 @@ @container.trigger event_type, data ?= {} # mixin = constructor of Draggable # self = Card - @mixin: (mixin) -> - @prototype.mixins = [] unless @prototype.mixins? - @prototype.mixins.push mixin + @mixin: (mixin, p...) -> + @prototype.mixins or= [] + console.log p + @prototype.mixins.push({mixin: mixin, params: p}) # GLOBAL EVENTS. # Subscribes to the given global event,