travis-web/assets/scripts/app/components.coffee
Piotr Sarnacki bbba892e7b Don't automatically toggle hook switches
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.
2014-02-12 17:58:19 +01:00

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)