mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 05:59:21 +03:00
ES2015 first look / babeljs
This commit is contained in:
parent
5dcceaaca5
commit
445cd155e5
123 changed files with 3214 additions and 3680 deletions
48
dev/Component/AbstracRadio.jsx
Normal file
48
dev/Component/AbstracRadio.jsx
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
import {_} from 'common';
|
||||
import ko from 'ko';
|
||||
import Utils from 'Common/Utils';
|
||||
import {AbstractComponent} from 'Component/Abstract';
|
||||
|
||||
class AbstracRadio extends AbstractComponent
|
||||
{
|
||||
/**
|
||||
* @param {Object} params
|
||||
*/
|
||||
constructor(params) {
|
||||
|
||||
super();
|
||||
|
||||
this.values = ko.observableArray([]);
|
||||
|
||||
this.value = params.value;
|
||||
if (Utils.isUnd(this.value) || !this.value.subscribe)
|
||||
{
|
||||
this.value = ko.observable('');
|
||||
}
|
||||
|
||||
this.inline = Utils.isUnd(params.inline) ? false : params.inline;
|
||||
this.readOnly = Utils.isUnd(params.readOnly) ? false : !!params.readOnly;
|
||||
|
||||
if (params.values)
|
||||
{
|
||||
this.values(_.map(params.values, (label, value) => {
|
||||
return {
|
||||
'label': label,
|
||||
'value': value
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
||||
this.click = _.bind(this.click, this);
|
||||
}
|
||||
|
||||
click(value) {
|
||||
if (!this.readOnly && value)
|
||||
{
|
||||
this.value(value.value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export {AbstracRadio, AbstracRadio as default};
|
||||
Loading…
Add table
Add a link
Reference in a new issue