
Hook switches are toggled in the controller "toggle" action, so if we toggle them in the component and then in the controller, it will just return to the original state.
22 lines
635 B
CoffeeScript
22 lines
635 B
CoffeeScript
Travis.TravisSwitchComponent = Ember.Component.extend
|
|
tagName: 'a'
|
|
classNames: ['travis-switch']
|
|
classNameBindings: ['_active:active']
|
|
|
|
# TODO: how to handle overriding properties to
|
|
# avoid naming it _action?
|
|
_active: (->
|
|
@get('target.active') || @get('active')
|
|
).property('target.active', 'active')
|
|
|
|
click: ->
|
|
target = @get('target')
|
|
if @get('toggleAutomatically') != 'false'
|
|
if target
|
|
@set('target.active', !@get('target.active'))
|
|
else
|
|
@set('active', !@get('active'))
|
|
# allow for bindings to propagate
|
|
Ember.run.next this, ->
|
|
@sendAction('action', target)
|