<commit_before>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/*
 * Copyright (c) 2014, Joyent, Inc.
 */

var React = require('react');
var Chosen = React.createClass({
    displayName: 'Chosen',
    componentDidUpdate: function() {
        // chosen doesn't refresh the options by itself, babysit it
        $(this.refs.select.getDOMNode()).trigger('chosen:updated');
    },
    propTypes: {
        onChange: React.PropTypes.func
    },
    componentDidMount: function(select) {
        $(this.refs.select.getDOMNode())
        .chosen({
            disable_search_threshold: this.props.disableSearchThreshold,
            no_results_text: this.props.noResultsText,
            max_selected_options: this.props.maxSelectedOptions,
            allow_single_deselect: this.props.allowSingleDeselect,
            width: this.props.width,
            search_contains: true
        })
        .on('chosen:maxselected', this.props.onMaxSelected)
        .on('chosen:showing_dropdown', this.props.onShowingDropdown)
        .on('chosen:hiding_dropdown', this.props.onHidingDropdown)
        .on('chosen:no_results', this.props.onNoResults)
        .on('chosen:ready', this.props.onReady)
        .change(this.props.onChange);
    },
    componentWillUnmount: function() {
        $(this.refs.select.getDOMNode()).off('chosen:ready chosen:maxselected chosen:showing_dropdown chosen:hiding_dropdown chosen:no_results change');
    },
    getDefaultProps: function() {
        return {
            width: '100%'
        }
    },
    activate: function() {
        $(this.refs.select.getDOMNode()).trigger('chosen:activate');
    },
    open: function() {
        $(this.refs.select.getDOMNode()).trigger('chosen:open')
    },
    close: function() {
        $(this.refs.select.getDOMNode()).data('chosen').close_field();
        $(this.refs.select.getDOMNode()).data('chosen').container.remove();
    },
    render: function() {
        return this.transferPropsTo(React.DOM.select({ref: 'select'}, this.props.children));
    }
});<commit_msg>ADMINUI-943 fix this.transferPropsTo... deprecation warning<commit_after>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/*
 * Copyright (c) 2014, Joyent, Inc.
 */

var React = require('react');
var $ = require('jquery');

var Chosen = React.createClass({
    displayName: 'Chosen',
    componentDidUpdate: function() {
        // chosen doesn't refresh the options by itself, babysit it
        $(this.refs.select.getDOMNode()).trigger('chosen:updated');
    },
    propTypes: {
        onChange: React.PropTypes.func
    },
    componentDidMount: function(select) {
        $(this.refs.select.getDOMNode())
        .chosen({
            disable_search_threshold: this.props.disableSearchThreshold,
            no_results_text: this.props.noResultsText,
            max_selected_options: this.props.maxSelectedOptions,
            allow_single_deselect: this.props.allowSingleDeselect,
            width: this.props.width,
            search_contains: true
        })
        .on('chosen:maxselected', this.props.onMaxSelected)
        .on('chosen:showing_dropdown', this.props.onShowingDropdown)
        .on('chosen:hiding_dropdown', this.props.onHidingDropdown)
        .on('chosen:no_results', this.props.onNoResults)
        .on('chosen:ready', this.props.onReady)
        .change(this.props.onChange);
    },
    componentWillUnmount: function() {
        $(this.refs.select.getDOMNode()).off('chosen:ready chosen:maxselected chosen:showing_dropdown chosen:hiding_dropdown chosen:no_results change');
    },
    getDefaultProps: function() {
        return {
            width: '100%'
        };
    },
    activate: function() {
        $(this.refs.select.getDOMNode()).trigger('chosen:activate');
    },
    open: function() {
        $(this.refs.select.getDOMNode()).trigger('chosen:open');
    },
    close: function() {
        $(this.refs.select.getDOMNode()).data('chosen').close_field();
        $(this.refs.select.getDOMNode()).data('chosen').container.remove();
    },
    render: function() {
        var props = this.props;
        this.props.ref = 'select';
        return React.DOM.select(props, this.props.children);
    }
});
{'fraction_non_alphanumeric': 0.14266696250277347, 'fraction_numerical': 0.005546927002440648, 'mean_word_length': 2.869527896995708, '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': '3714318', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1338, 'n_words': 248}