<commit_before>/*
 * Copyright (C) 2013 salesforce.com, inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
({
    /**
     * Behavior when the data from one of its data providers changes
     *
     * @param {Component} component Potentially non-concrete (ui:abstractList) component instance.
     * @param event ui:dataChanged.
     * @param {Function} callback An optional callback to invoke after 'v.items' has been replaced.
     */
    handleDataChange: function(component, event, callback) {
        var concrete = component.getConcreteComponent();

        concrete.set("v.items", event.getParam("data"));
        this.showLoading(component, false);

        if (callback) {
            callback();
        }
    },

    /** Behavior to prepare the list for new data before a refresh **/
    beforeRefresh: function(component, event) {
        component.getConcreteComponent().set("v.items", []);
    },

    updateEmptyListContent:function (component) {
        // make sure we are referencing a concrete component.
        var concrete_component = component.getConcreteComponent();
        var items = concrete_component.get("v.items");
        var has_items = items != null && items.length > 0;
        $A.util[has_items ? "removeClass" : "addClass"](concrete_component.getElement(), "showEmptyContent");
    },

    /** Behavior for triggering data providers on initialization **/
    initTriggerDataProviders: function(component) {
        this.triggerDataProvider(component);
    },

    init: function(component) {
        this.initDataProvider(component);
        this.initPagers(component);
    },

    initDataProvider: function(component) {
        var dataProviders = component.get("v.dataProvider");

        if (dataProviders && dataProviders.length && dataProviders.length > 0) {
            for (var i = 0; i < dataProviders.length; i++) {
                dataProviders[i].addHandler("onchange", component, "c.handleDataChange");
            }

            component._dataProviders = dataProviders;
        }
    },

    initPagers: function(component) {
        var facets = component.getFacets();
        var pagers = [];

        // walk each facet looking for instances of ui:pager
        for (var i=0, len=facets.length; i<len; i++) {
            var facet = facets[i];

            for (var n = 0; n < facet.len; n++) {
                var c = facet[n];
                if (c.getDef().getDescriptor().getQualifiedName() != "markup://aura:unescapedHtml") {
                    if (c.isInstanceOf("ui:pager")) {
                        pagers.push(c);
                    } else {
                        pagers = pagers.concat(c.find({instancesOf:"ui:pager"}));
                    }
                }
            }
        }

        // wireup handlers and values
//      var chainedAttrs = ["currentPage", "pageSize", "totalItems"];
        var j = pagers.length;
        while (j--) {
            var pager = pagers[j];
            pager.addHandler("onPageChange", component, "c.handlePageChange");<commit_msg>facet.len -> facet.length typo fix @bug W-2536665@<commit_after>/*
 * Copyright (C) 2013 salesforce.com, inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
({
    /**
     * Behavior when the data from one of its data providers changes
     *
     * @param {Component} component Potentially non-concrete (ui:abstractList) component instance.
     * @param event ui:dataChanged.
     * @param {Function} callback An optional callback to invoke after 'v.items' has been replaced.
     */
    handleDataChange: function(component, event, callback) {
        var concrete = component.getConcreteComponent();

        concrete.set("v.items", event.getParam("data"));
        this.showLoading(component, false);

        if (callback) {
            callback();
        }
    },

    /** Behavior to prepare the list for new data before a refresh **/
    beforeRefresh: function(component, event) {
        component.getConcreteComponent().set("v.items", []);
    },

    updateEmptyListContent:function (component) {
        // make sure we are referencing a concrete component.
        var concrete_component = component.getConcreteComponent();
        var items = concrete_component.get("v.items");
        var has_items = items != null && items.length > 0;
        $A.util[has_items ? "removeClass" : "addClass"](concrete_component.getElement(), "showEmptyContent");
    },

    /** Behavior for triggering data providers on initialization **/
    initTriggerDataProviders: function(component) {
        this.triggerDataProvider(component);
    },

    init: function(component) {
        this.initDataProvider(component);
        this.initPagers(component);
    },

    initDataProvider: function(component) {
        var dataProviders = component.get("v.dataProvider");

        if (dataProviders && dataProviders.length && dataProviders.length > 0) {
            for (var i = 0; i < dataProviders.length; i++) {
                dataProviders[i].addHandler("onchange", component, "c.handleDataChange");
            }

            component._dataProviders = dataProviders;
        }
    },

    initPagers: function(component) {
        var facets = component.getFacets();
        var pagers = [];

        // walk each facet looking for instances of ui:pager
        for (var i = 0, len = facets.length; i < len; i++) {
            var facet = facets[i];

            for (var n = 0; n < facet.length; n++) {
                var c = facet[n];
                if (c.getDef().getDescriptor().getQualifiedName() != "markup://aura:unescapedHtml") {
                    if (c.isInstanceOf("ui:pager")) {
                        pagers.push(c);
                    } else {
                        pagers = pagers.concat(c.find({instancesOf: "ui:pager"}));
                    }
                }
            }
        }

        // wireup handlers and values
//      var chainedAttrs = ["currentPage", "pageSize", "totalItems"];
        var j = pagers.length;
        while (j--) {
            var pager = pagers[j];
            pager.addHandler("onPageChange", component, "c.handlePageChange");
{'fraction_non_alphanumeric': 0.11588341932784828, 'fraction_numerical': 0.004601868637567982, 'mean_word_length': 2.376647834274953, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1696141', 'n_tokens_mistral': 1962, 'n_tokens_neox': 1872, 'n_words': 554}