import Ember from 'ember';

export default Ember.Component.extend({
  tagName: 'span',
  theme: 'default',
  off: 'Off',
  on: 'On',
  toggled: false,

  inputClasses: Ember.observer('themeClass', 'inputCheckbox', function () {
    var themeClass = this.get('themeClass');
    var input = this.get('inputCheckbox');

    if (input) {
      var inputClasses = input.get('classNames') || [];

      input.set('classNames', inputClasses.concat(['x-toggle', themeClass]));
    }
  }).on('init'),

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

    return 'x-toggle-' + theme;
  }),

  generatedId: Ember.computed(function () {
    return this.get('elementId') + '-x-toggle';
  }),

  wasToggled: Ember.observer('toggled', function () {
    var toggled = this.get('toggled');
    
    this.sendAction('toggle', toggled);
  }).on('init')
});

import Ember from 'ember';

var observer = Ember.observer;
var on = Ember.on;
var computed = Ember.computed;

export default Ember.Component.extend({
  tagName: 'span',
  theme: 'default',
  off: 'Off',
  on: 'On',
  toggled: false,

  inputClasses: on('init', observer('themeClass', 'inputCheckbox', function () {
    var themeClass = this.get('themeClass');
    var input = this.get('inputCheckbox');

    if (input) {
      var inputClasses = input.get('classNames') || [];

      input.set('classNames', inputClasses.concat(['x-toggle', themeClass]));
    }
  }),

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

    return 'x-toggle-' + theme;
  }),

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

  wasToggled: on('init', observer('toggled', function () {
    var toggled = this.get('toggled');
    
    this.sendAction('toggle', toggled);
  })
});

Use local variables to make methods parse easier.
Use local variables to make methods parse easier.

* Stash local variables, and use them inline (seems to be easier to read to me).
* Do not require function prototype extensions (`Function.prototype.on` was used before).