<commit_before>slicer.views.ControlWidget = girder.View.extend({
    events: {
        'change input,select': '_input',
        'changeColor': '_input',
        'click .s-select-file-button': '_selectFile'
    },

    initialize: function () {
        this.listenTo(this.model, 'change', this.render);
        this.listenTo(this.model, 'destroy', this.remove);
        this.listenTo(this.model, 'invalid', this.invalid);
    },

    render: function (_, options) {
        this.$('.form-group').removeClass('has-error');
        this.model.isValid();
        if (options && options.norender) {
            return this;
        }
        this.$el.html(this.template()(this.model.attributes));
        this.$('.s-control-item[data-type="range"] input').slider();
        this.$('.s-control-item[data-type="color"] .input-group').colorpicker({});
        return this;
    },

    remove: function () {
        this.$('.s-control-item[data-type="color"] .input-group').colorpicker('destroy');
        this.$('.s-control-item[data-type="range"] input').slider('destroy');
        this.$el.empty();
    },

    /**
     * Set classes on the input element to indicate to the user that the current value
     * is invalid.  This is automatically triggered by the model's "invalid" event.
     */
    invalid: function () {
        this.$('.form-group').addClass('has-error');
    },

    /**
     * For image types, this sets the current value to the loaded image.  To be
     * called both on initialization and whenever the viewed image changes.
     *
     * TODO: restore this in the main application code
     *
    _useLoadedImage: function () {
        var current = this.model.get('value');

        if (current) {
            this.stopListening(current);
        }

        // get the large image file id, and trigger a change when fetched
        current = slicer.dialogs.image.model.get('value');

        if (!current) {
            return;
        }

        current.once('g:fetched', function () {
            var largeImage = current.get('largeImage');
            var fileId = largeImage && (largeImage.originalId || largeImage.fileId);
            var file;

            if (fileId) {
                file = new girder.models.FileModel({_id: fileId});
                this.model.set('value', file, {trigger: false});

                file.once('g:fetched', function () {
                    this.model.trigger('change', this.model);
                }, this).fetch();
            }
        }, this).fetch();
    },
     */

    /**
     * Type definitions mapping used internally.  Each widget type
     * specifies it's jade template and possibly more custimizations
     * as needed.
     */<commit_msg>Remove TODO comment handled in latest histomicstk<commit_after>slicer.views.ControlWidget = girder.View.extend({
    events: {
        'change input,select': '_input',
        'changeColor': '_input',
        'click .s-select-file-button': '_selectFile'
    },

    initialize: function () {
        this.listenTo(this.model, 'change', this.render);
        this.listenTo(this.model, 'destroy', this.remove);
        this.listenTo(this.model, 'invalid', this.invalid);
    },

    render: function (_, options) {
        this.$('.form-group').removeClass('has-error');
        this.model.isValid();
        if (options && options.norender) {
            return this;
        }
        this.$el.html(this.template()(this.model.attributes));
        this.$('.s-control-item[data-type="range"] input').slider();
        this.$('.s-control-item[data-type="color"] .input-group').colorpicker({});
        return this;
    },

    remove: function () {
        this.$('.s-control-item[data-type="color"] .input-group').colorpicker('destroy');
        this.$('.s-control-item[data-type="range"] input').slider('destroy');
        this.$el.empty();
    },

    /**
     * Set classes on the input element to indicate to the user that the current value
     * is invalid.  This is automatically triggered by the model's "invalid" event.
     */
    invalid: function () {
        this.$('.form-group').addClass('has-error');
    },

    /**
     * Type definitions mapping used internally.  Each widget type
     * specifies it's jade template and possibly more custimizations
     * as needed.
     */
{'fraction_non_alphanumeric': 0.1544356711565258, 'fraction_numerical': 0.0, 'mean_word_length': 2.2752851711026616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6580288', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1185, 'n_words': 277}