{"size": 2389, "ext": "js", "max_stars_repo_path": "node_modules/ng2-bootstrap/buttons/button-radio.directive.js", "max_stars_repo_name": "chenze4949/startuppi-web", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/ng2-bootstrap/buttons/button-radio.directive.js", "max_issues_repo_name": "chenze4949/startuppi-web", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "node_modules/ng2-bootstrap/buttons/button-radio.directive.js", "max_forks_repo_name": "chenze4949/startuppi-web", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 34.6231884058, "max_line_length": 123, "alphanum_fraction": 0.6169945584}
"use strict";
var core_1 = require('@angular/core');
var forms_1 = require('@angular/forms');
exports.RADIO_CONTROL_VALUE_ACCESSOR = {
    provide: forms_1.NG_VALUE_ACCESSOR,
    useExisting: core_1.forwardRef(function () { return ButtonRadioDirective; }),
    multi: true
};
var ButtonRadioDirective = (function () {
    function ButtonRadioDirective(el) {
        this.onChange = Function.prototype;
        this.onTouched = Function.prototype;
        this.el = el;
    }
    Object.defineProperty(ButtonRadioDirective.prototype, "isActive", {
        get: function () {
            return this.btnRadio === this.value;
        },
        enumerable: true,
        configurable: true
    });
    ButtonRadioDirective.prototype.onClick = function () {
        if (this.el.nativeElement.attributes.disabled) {
            return;
        }
        if (this.uncheckable && this.btnRadio === this.value) {
            this.value = undefined;
        }
        else {
            this.value = this.btnRadio;
        }
        this.onTouched();
        this.onChange(this.value);
    };
    ButtonRadioDirective.prototype.ngOnInit = function () {
        this.uncheckable = typeof this.uncheckable !== 'undefined';
    };
    ButtonRadioDirective.prototype.onBlur = function () {
        this.onTouched();
    };
    // ControlValueAccessor
    // model -> view
    ButtonRadioDirective.prototype.writeValue = function (value) {
        this.value = value;
    };
    ButtonRadioDirective.prototype.registerOnChange = function (fn) {
        this.onChange = fn;
    };
    ButtonRadioDirective.prototype.registerOnTouched = function (fn) {
        this.onTouched = fn;
    };
    ButtonRadioDirective.decorators = [
        { type: core_1.Directive, args: [{ selector: '[btnRadio]', providers: [exports.RADIO_CONTROL_VALUE_ACCESSOR] },] },
    ];
    /** @nocollapse */
    ButtonRadioDirective.ctorParameters = [
        { type: core_1.ElementRef, },
    ];
    ButtonRadioDirective.propDecorators = {
        'btnRadio': [{ type: core_1.Input },],
        'uncheckable': [{ type: core_1.Input },],
        'value': [{ type: core_1.Input },],
        'isActive': [{ type: core_1.HostBinding, args: ['class.active',] },],
        'onClick': [{ type: core_1.HostListener, args: ['click',] },],
    };
    return ButtonRadioDirective;
}());
exports.ButtonRadioDirective = ButtonRadioDirective;
