<commit_before><link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-selector/iron-selector.html">

<dom-module id="ugo-collection">
    <link rel="import" type="css" href="ugo-collection.css">
    <template>
        <div class="ugo-collection-menu">
            <iron-selector id="list" class="ugo-collection-list" selected="{{selected}}" on-tap="removeItem">
                <template is="dom-repeat" items="{{menuItems}}" index-as="id" on-dom-change="onListRender">
                    <div class="iron-selector-item" data-error$="{{item.hasError}}"><span>{{item.title}}</span>
                        <button type="button" data-id$="{{id}}">{{item.removeText}}</button>
                        <div class="ugo-collection-arrow"></div>
                    </div>
                </template>
            </iron-selector>
            <button id="add" disabled$="{{disabledAdd}}" on-tap="addItem">{{addText}}</button>
        </div>
        <content id="items" select="[ugo-collection-item]"></content>
    </template>
</dom-module>
<script>
    Polymer({
        is: 'ugo-collection',

        /**
         * @warning Properties order is important !
         */
        properties: {
            /**
             * Text on add button
             */
            addText: {
                type: String,
                value: 'add'
            },

            /**
             * Text on remove buttons
             */
            removeText: {
                type: String,
                value: 'remove',
                observer: 'removeTextChanged'
            },

            /**
             * Text on create
             */
            createText: {
                type: String,
                value: 'Editing...'
            },

            /**
             * property storing html used to generate collection's item
             */
            prototypeAttribute: {
                type: String,
                value: 'data-prototype'
            },

            /**
             * the part to parse in the html property
             */
            prototypeProperty: {
                type: String,
                value: '__name__'
            },

            /**
             * use to identify collection items
             */
            itemAttribute: {
                type: String,
                value: 'ugo-collection-item'
            },

            /**
             * class used to mark collection's item selected
             */
            itemSelectedClass: {
                type: String,
                value: 'ugo-collection-selected'
            },

            /**
             * Error class
             */
            errorClass: {
                type: String,
                value: 'has-error'
            },

            /**
             * nestedErrorSelector
             */
            nestedErrorSelector: {
                type: String,
                value: '.has-error'
            },

            /**
             * selected index
             */
            selected: {
                type: Number,
                value: -1,
                observer: 'selectedChanged'
            },

            /**
             * Property use to disable the add button
             */
            disabledAdd: {
                type: Boolean,
                value: false,
                readOnly: true
            },

            /**
             * Property use to disable the add button
             */
            menuItems: {
                type: Array,
                value: [],
                readOnly: true,
                notify: true,
                observer: 'menuItemsChanged'
            }
        },

        /**
         * Used to block infinite loop in selectedChanged method
         */
        prev: null,

        /**
         * job interval
         */
        interval: 500,

        /**
         * init
         */
        ready: function() {
            this.prev = null;
            this.resumerChangeListener = this.onResumerChangeHandler.bind(this);

            this.async(function() {
                var selectedChanged = false;
                var menuItems = [];
                [].forEach.call(this.items, function(item, index) {
                    var hasError = this.hasErrorClass(index);
                    menuItems.push({title: this.getTitle(item, index), hasError: hasError, removeText: this.removeText});
                    if (hasError && !selectedChanged) {
                        this.selected = index;
                        selectedChanged = true;
                    }
                }.bind(this));
                this._setMenuItems(menuItems);
            });
        },

        /**
         * Dom repeat render event
         * We need to to this because the selected value is selected to fast
         */
        onListRender: function() {<commit_msg>use attached instead of ready<commit_after><link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-selector/iron-selector.html">

<dom-module id="ugo-collection">
    <link rel="import" type="css" href="ugo-collection.css">
    <template>
        <div class="ugo-collection-menu">
            <iron-selector id="list" class="ugo-collection-list" selected="{{selected}}" on-tap="removeItem">
                <template is="dom-repeat" items="{{menuItems}}" index-as="id" on-dom-change="onListRender">
                    <div class="iron-selector-item" data-error$="{{item.hasError}}"><span>{{item.title}}</span>
                        <button type="button" data-id$="{{id}}">{{item.removeText}}</button>
                        <div class="ugo-collection-arrow"></div>
                    </div>
                </template>
            </iron-selector>
            <button id="add" disabled$="{{disabledAdd}}" on-tap="addItem">{{addText}}</button>
        </div>
        <content id="items" select="[ugo-collection-item]"></content>
    </template>
</dom-module>
<script>
    Polymer({
        is: 'ugo-collection',

        /**
         * @warning Properties order is important !
         */
        properties: {
            /**
             * Text on add button
             */
            addText: {
                type: String,
                value: 'add'
            },

            /**
             * Text on remove buttons
             */
            removeText: {
                type: String,
                value: 'remove',
                observer: 'removeTextChanged'
            },

            /**
             * Text on create
             */
            createText: {
                type: String,
                value: 'Editing...'
            },

            /**
             * property storing html used to generate collection's item
             */
            prototypeAttribute: {
                type: String,
                value: 'data-prototype'
            },

            /**
             * the part to parse in the html property
             */
            prototypeProperty: {
                type: String,
                value: '__name__'
            },

            /**
             * use to identify collection items
             */
            itemAttribute: {
                type: String,
                value: 'ugo-collection-item'
            },

            /**
             * class used to mark collection's item selected
             */
            itemSelectedClass: {
                type: String,
                value: 'ugo-collection-selected'
            },

            /**
             * Error class
             */
            errorClass: {
                type: String,
                value: 'has-error'
            },

            /**
             * nestedErrorSelector
             */
            nestedErrorSelector: {
                type: String,
                value: '.has-error'
            },

            /**
             * selected index
             */
            selected: {
                type: Number,
                value: -1,
                observer: 'selectedChanged'
            },

            /**
             * Property use to disable the add button
             */
            disabledAdd: {
                type: Boolean,
                value: false,
                readOnly: true
            },

            /**
             * Property use to disable the add button
             */
            menuItems: {
                type: Array,
                value: [],
                readOnly: true,
                notify: true,
                observer: 'menuItemsChanged'
            }
        },

        /**
         * Used to block infinite loop in selectedChanged method
         */
        prev: null,

        /**
         * job interval
         */
        interval: 500,

        /**
         * init
         */
        attached: function() {
            this.prev = null;
            this.resumerChangeListener = this.onResumerChangeHandler.bind(this);

            this.async(function() {
                var selectedChanged = false;
                var menuItems = [];
                [].forEach.call(this.items, function(item, index) {
                    var hasError = this.hasErrorClass(index);
                    menuItems.push({title: this.getTitle(item, index), hasError: hasError, removeText: this.removeText});
                    if (hasError && !selectedChanged) {
                        this.selected = index;
                        selectedChanged = true;
                    }
                }.bind(this));
                this._setMenuItems(menuItems);
            });
        },

        /**
         * Dom repeat render event
         * We need to to this because the selected value is selected to fast
         */
        onListRender: function() {
{'fraction_non_alphanumeric': 0.11596277738010022, 'fraction_numerical': 0.0008180795582370385, 'mean_word_length': 1.0707177641329664, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, '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': '2055160', 'n_tokens_mistral': 2391, 'n_tokens_neox': 2233, 'n_words': 510}