-
Notifications
You must be signed in to change notification settings - Fork 332
/
paper-radio-base.js
61 lines (52 loc) · 1.63 KB
/
paper-radio-base.js
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
/**
* @module ember-paper
*/
import Component from '@ember/component';
import { computed } from '@ember/object';
import { assert } from '@ember/debug';
import layout from '../templates/components/paper-radio-base';
import FocusableMixin from 'ember-paper/mixins/focusable-mixin';
import RippleMixin from 'ember-paper/mixins/ripple-mixin';
import ColorMixin from 'ember-paper/mixins/color-mixin';
import { invokeAction } from 'ember-invoke-action';
/**
* @class PaperRadio
* @extends Ember.Component
* @uses FocusableMixin
* @uses ColorMixin
* @uses RippleMixin
*/
export default Component.extend(FocusableMixin, RippleMixin, ColorMixin, {
layout,
tagName: 'md-radio-button',
classNames: ['md-default-theme'],
classNameBindings: ['checked:md-checked'],
tabindex: null,
toggle: false,
/* Ripple Overrides */
rippleContainerSelector: '.md-container',
center: true,
dimBackground: false,
fitRipple: true,
/* FocusableMixin Overrides */
focusOnlyOnKey: true,
// Lifecycle hooks
init() {
assert('{{paper-radio}} requires an `onChange` action or null for no action.', this.get('onChange') !== undefined);
this._super(...arguments);
},
checked: computed('groupValue', 'value', function() {
return this.get('groupValue') === this.get('value');
}),
click() {
if (!this.get('disabled')) {
if (this.get('toggle')) {
invokeAction(this, 'onChange', this.get('checked') ? null : this.get('value'));
} else {
invokeAction(this, 'onChange', this.get('value'));
}
}
// Prevent bubbling, if specified. If undefined, the event will bubble.
return this.get('bubbles');
}
});