Skip to content

Commit

Permalink
Convert to new CP syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Radchenko committed Jul 21, 2015
1 parent fe7f8fe commit ac3ccba
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions addon/components/x-toggle/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,39 @@ export default Ember.Component.extend({
'disabled:x-toggle-container-disabled'
],

onLabel: computed('on', function () {
return this.get('on').indexOf(':') > -1 ?
this.get('on').substr(0,this.get('on').indexOf(':')) :
this.get('on');
onLabel: computed('on', {
get() {
return this.get('on').indexOf(':') > -1 ?
this.get('on').substr(0,this.get('on').indexOf(':')) :
this.get('on');
}
}),

offLabel: computed('off', function () {
return this.get('off').indexOf(':') > -1 ?
this.get('off').substr(0,this.get('off').indexOf(':')) :
this.get('off');
offLabel: computed('off', {
get() {
return this.get('off').indexOf(':') > -1 ?
this.get('off').substr(0,this.get('off').indexOf(':')) :
this.get('off');
}
}),

themeClass: computed('theme', function () {
var theme = this.get('theme') || 'default';
themeClass: computed('theme', {
get() {
var theme = this.get('theme') || 'default';

return 'x-toggle-' + theme;
return `x-toggle-${theme}`;
}
}),

forId: computed(function () {
return this.get('elementId') + '-x-toggle';
forId: computed({
get() {
return `${this.get('elementId')}-x-toggle`;
}
}),

toggledChanged: observer('isToggled', function () {
var debounce = this.get('debounce');

if (debounce) {
run.cancel(debounce);
}
Expand All @@ -55,7 +64,7 @@ export default Ember.Component.extend({
var onState = onIndex > -1 ? this.get('on').substr(onIndex + 1) : true;
var state = toggled ? onState : offState;

this.sendAction('on-toggle', toggled, state);
this.sendAction('ontoggle', toggled, state);
this.set('debounce', null);
}, 500);

Expand Down

0 comments on commit ac3ccba

Please sign in to comment.