diff --git a/assets/scripts/app/components.coffee b/assets/scripts/app/components.coffee index 09a177fb..da423edd 100644 --- a/assets/scripts/app/components.coffee +++ b/assets/scripts/app/components.coffee @@ -1,19 +1,9 @@ Travis.TravisSwitchComponent = Ember.Component.extend tagName: 'a' classNames: ['travis-switch'] - classNameBindings: ['_active:active'] + classNameBindings: ['active'] - # TODO: how to handle overriding properties to - # avoid naming it _action? - _active: (-> - @get('target.active') || @get('active') - ).property('target.active', 'active') + activeBinding: 'target.active' click: -> - if target = @get('target') - @set('target.active', !@get('target.active')) - else - @set('active', !@get('active')) - # allow for bindings to propagate - Ember.run.next this, -> - @sendAction('action', target) + @sendAction('action', @get('target')) diff --git a/assets/scripts/app/templates/components/travis-switch.hbs b/assets/scripts/app/templates/components/travis-switch.hbs index 18617602..e7b20837 100644 --- a/assets/scripts/app/templates/components/travis-switch.hbs +++ b/assets/scripts/app/templates/components/travis-switch.hbs @@ -1,4 +1,4 @@ -{{#if _active}} +{{#if active}} ON {{else}} OFF