all files / addon/components/ el-radio-input.js

0% Statements 0/7
0% Branches 0/4
0% Functions 0/3
0% Lines 0/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66                                                                                                                                   
import Component from '@ember/component';
// import layout from '../templates/components/el-radio-input';
import { computed } from '@ember/object';
import { isEqual } from '@ember/utils';
import { run } from '@ember/runloop';
 
 
export default Component.extend({
  // layout,
 
  tagName: 'input',
  type: 'radio',
 
 
 
  // value - required
  // model - required
 
  // autofocus - boolean
  // disabled - optional
  // name - optional
  // required - optional
  // radioClass - string
  // radioId - string
  // tabindex - number
  // ariaLabelledby - string
  // ariaDescribedby - string
 
  defaultLayout: null, // ie8 support
 
  attributeBindings: [
    'autofocus',
    'checked',
    'disabled',
    'name',
    'required',
    'tabindex',
    'type',
    'value',
    'ariaLabelledby:aria-labelledby',
    'ariaDescribedby:aria-describedby',
    'checked:aria-checked'
  ],
 
  checked: computed('model', 'value', function () {
    return isEqual(this.get('model'), this.get('value'));
  }).readOnly(),
 
  sendChangedAction() {
    if (this.get('changed')) {
      this.get('changed')(this.get('value'), this.get('item'));
    }
  },
 
  change() {
    let value = this.get('value');
    let model = this.get('model');
 
    if (model !== value) {
      // this.set('model', value); // violates DDAU
      run.once(this, 'sendChangedAction');
    }
  }
});