<commit_before>/*
 * Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
 * http://paperjs.org/
 *
 * Copyright (c) 2011 - 2014, <NAME> & <NAME>
 * http://scratchdisk.com/ & http://jonathanpuckey.com/
 *
 * Distributed under the MIT license. See LICENSE file for details.
 *
 * All rights reserved.
 */

 /**
  * @name Pane
  * @class
  */
var Pane = Base.extend(Callback, /** @lends Pane# */{
    _class: 'Pane',
    _events: [ 'onChange' ],
    // Defaults for internals
    _enabled: true,

    initialize: function Pane(components, values, parent, parentRow) {
        if (!values)
            values = {};
        this._table = !parentRow && DomElement.create('table', {
            class: 'palettejs-pane'
        });
        // NOTE: We modify the actual passed components in the root pane, and
        // also the values objects, so the newly created components and their
        // values can easily be referenced from outside.
        this._components = parent ? {} : components;
        this._values = values;
        var numCells = 0;
        this._numCells = 0;
        for (var name in components) {
            var component = components[name];
            if (Base.isPlainObject(component)) {
                var row = parentRow || DomElement.addChildren(this._table,
                        ['tr', { class: 'palettejs-row' }])[0];
                this._components[name] = new Component(this, name, component,
                        values, row, parent);
                numCells = Math.max(numCells, this._numCells);
                if (!parentRow)
                    this._numCells = 0;
            }
        }
        this._numCells = numCells;
        // Override in case we made a copy, see above.
        components = this._components;
        Base.each(components, function(component, name) {
            // Update colspan in all components that are not nested in another
            // component.
            if (numCells > 2 && component._cell && !component._nested) {
                DomElement.set(component._cell, 'colspan', numCells - 1);
            }
            // Now replace each entry in values with a getter / setters so we
            // can directly link the value to the component and  observe change.
            Base.define(values, name, {
                enumerable: true,
                configurable: true,
                get: function() {
                    return component.getValue();
                },
                set: function(val) {
                    component.setValue(val);
                }
            });
        });
    },

    getComponents: function() {
        return this._components;
    },

    getValues: function() {
        return this._values;
    },

    getEnabled: function() {
        return this._enabled;
    },

    setEnabled: function(enabled) {
        this._enabled = enabled;
        for (var i in this._components)
            this._components[i].setEnabled(enabled, true);
    },

    /**
     * Resets the values of the components to their
     * {@link Component#defaultValue}.
     */
    reset: function() {
        for (var i in this._components)
            this._components[i].reset();
    }
});
<commit_msg>Clean up Pane code a bit.<commit_after>/*
 * Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
 * http://paperjs.org/
 *
 * Copyright (c) 2011 - 2014, <NAME> & <NAME>
 * http://scratchdisk.com/ & http://jonathanpuckey.com/
 *
 * Distributed under the MIT license. See LICENSE file for details.
 *
 * All rights reserved.
 */

 /**
  * @name Pane
  * @class
  */
var Pane = Base.extend(Callback, /** @lends Pane# */{
    _class: 'Pane',
    _events: [ 'onChange' ],
    // Defaults for internals
    _enabled: true,

    initialize: function Pane(components, values, parent, parentRow) {
        if (!values)
            values = {};
        this._table = !parentRow && DomElement.create('table', {
            class: 'palettejs-pane'
        });
        // NOTE: We modify the actual passed components in the root pane, and
        // also the values objects, so the newly created components and their
        // values can easily be referenced from outside.
        var comps = this._components = parent ? {} : components;
        this._values = values;
        var numCells = 0;
        this._numCells = 0;
        for (var name in components) {
            var component = components[name];
            if (Base.isPlainObject(component)) {
                var row = parentRow || DomElement.addChildren(this._table,
                        ['tr', { class: 'palettejs-row' }])[0];
                comps[name] = new Component(this, name, component,
                        values, row, parent);
                numCells = Math.max(numCells, this._numCells);
                // Do not reset cell counter if all components go to the same
                // parent row.
                if (!parentRow)
                    this._numCells = 0;
            }
        }
        this._numCells = numCells;
        Base.each(comps, function(component, name) {
            // Update colspan in all components that are not nested in another
            // component.
            if (numCells > 2 && component._cell && !component._nested) {
                DomElement.set(component._cell, 'colspan', numCells - 1);
            }
            // Now replace each entry in values with a getter / setters so we
            // can directly link the value to the component and  observe change.
            Base.define(values, name, {
                enumerable: true,
                configurable: true,
                get: function() {
                    return component.getValue();
                },
                set: function(val) {
                    component.setValue(val);
                }
            });
        });
    },

    getComponents: function() {
        return this._components;
    },

    getValues: function() {
        return this._values;
    },

    getEnabled: function() {
        return this._enabled;
    },

    setEnabled: function(enabled) {
        this._enabled = enabled;
        for (var i in this._components)
            this._components[i].setEnabled(enabled, true);
    },

    /**
     * Resets the values of the components to their
     * {@link Component#defaultValue}.
     */
    reset: function() {
        for (var i in this._components)
            this._components[i].reset();
    }
});

{'fraction_non_alphanumeric': 0.11169635941130907, 'fraction_numerical': 0.004337722695584818, 'mean_word_length': 1.6933667083854818, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '3774988', 'n_tokens_mistral': 1767, 'n_tokens_neox': 1666, 'n_words': 510}