{"size": 834, "ext": "js", "max_stars_repo_path": "20181102/plugins/push/frontend/public/javascripts/component.input.js", "max_stars_repo_name": "zengxingqi/countly-node-server", "max_stars_repo_stars_event_min_datetime": "2019-09-18T12:39:42.000Z", "max_stars_repo_stars_event_max_datetime": "2019-09-18T12:39:42.000Z", "max_issues_repo_path": "20181102/plugins/push/frontend/public/javascripts/component.input.js", "max_issues_repo_name": "zengxingqi/countly-node-server", "max_issues_repo_issues_event_min_datetime": "2019-09-18T12:35:10.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-18T12:38:22.000Z", "max_forks_repo_path": "20181102/plugins/push/frontend/public/javascripts/component.input.js", "max_forks_repo_name": "zengxingqi/countly-node-server", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 34.75, "max_line_length": 154, "alphanum_fraction": 0.5791366906}
'use strict';

/* jshint undef: true, unused: true */
/* globals m */

window.component('input', function(input) {
    input.controller = function(opts){
        if (!(this instanceof input.controller)) {
            return new input.controller(opts);
        }

        this.opts = opts;
        this.value = typeof opts.value === 'function' ? opts.value : m.prop(opts.value);
    };
    input.view = function(ctrl){
        var pls = (typeof ctrl.opts.placeholder === 'function' ? ctrl.opts.placeholder() : ctrl.opts.placeholder) || '';

        return m('input.comp-input' + (ctrl.opts.class ? '.' + ctrl.opts.class : ''), {placeholder: pls, value: ctrl.value() || '', oninput: function(ev){
            ctrl.value(ev.target.value);
            if (ctrl.opts.onchange) { ctrl.opts.onchange(ctrl.value()); }
        }});
    };
});
