<commit_before>(function(root, factory){
    'use strict';
    if(typeof define === 'function' && define.amd){
        define([], function(){
            return factory(root.jQuery, root._);
        });
    }else{
        root.tabler.removeColumns = factory(root.jQuery, root._);
    }
})(this, function($, _){
    'use strict';
    function getLinkHtml(specIds){
        return '<a href class="removeColumn" data-ids="' + _.escape(JSON.stringify(specIds)) + '">x</a>';
    }

    /*
     *
    **/
    function RemoveColumns(options){
        _.extend(this, options || {});
    }
    RemoveColumns.pluginName = 'removeColumns';

    function setupColumnGroups(columnGrouper, spec){
        var groups = columnGrouper.getColumnGroups(spec);

        _(groups).forEach(function(groupSpec){
            var oldFormatter = columnGrouper.formatters[groupSpec.groupName],
                specs = _(spec).filter(function(spec){
                    return spec.groupName == groupSpec.groupName;
                });

            if(!specs.length || _(specs).any(function(spec){
                    return spec.toggleable === false;
                })){
                return;
            }

            columnGrouper.formatters[groupSpec.groupName] = function(groupSpec){
                var html = groupSpec.groupName;

                if(oldFormatter){
                    html = oldFormatter.call(this, groupSpec);
                }
                return getLinkHtml(_(specs).pluck('id')) + html;
            };
        });
    }

    _.extend(RemoveColumns.prototype, {
        attach: function(table){
            var self = this;

            _(table.spec).forEach(function(spec){
                var oldFormatter = spec.headerFormatter;

                spec.headerFormatter = function(spec){
                    var html = '';
                    if(oldFormatter){
                        html = oldFormatter.call(this, spec);
                    }

                    if(spec.toggleable === false){
                        return html;
                    }

                    return getLinkHtml([spec.id]) + html;
                };
            });

            // NOTE: To work correctly with columnGrouper this plugin must be *after* that one in the array
            if(table.columnGrouper){
                setupColumnGroups(table.columnGrouper, table.spec);
            }

            table.$el.delegate('th a.removeColumn', 'click', function(e){
                e.preventDefault();

                var ids = $(e.target).data('ids');

                _([].concat(ids)).forEach(function(id){
                    var field = table.getField({id: id});<commit_msg>Fixed column headers not displaying when removeColumns plugin enabled<commit_after>(function(root, factory){
    'use strict';
    if(typeof define === 'function' && define.amd){
        define([], function(){
            return factory(root.jQuery, root._);
        });
    }else{
        root.tabler.removeColumns = factory(root.jQuery, root._);
    }
})(this, function($, _){
    'use strict';
    function getLinkHtml(specIds){
        return '<a href class="removeColumn" data-ids="' + _.escape(JSON.stringify(specIds)) + '">x</a>';
    }

    /*
     *
    **/
    function RemoveColumns(options){
        _.extend(this, options || {});
    }
    RemoveColumns.pluginName = 'removeColumns';

    function setupColumnGroups(columnGrouper, spec){
        var groups = columnGrouper.getColumnGroups(spec);

        _(groups).forEach(function(groupSpec){
            var oldFormatter = columnGrouper.formatters[groupSpec.groupName],
                specs = _(spec).filter(function(spec){
                    return spec.groupName == groupSpec.groupName;
                });

            if(!specs.length || _(specs).any(function(spec){
                    return spec.toggleable === false;
                })){
                return;
            }

            columnGrouper.formatters[groupSpec.groupName] = function(groupSpec){
                var html = groupSpec.groupName;

                if(oldFormatter){
                    html = oldFormatter.call(this, groupSpec);
                }
                return getLinkHtml(_(specs).pluck('id')) + html;
            };
        });
    }

    _.extend(RemoveColumns.prototype, {
        attach: function(table){
            var self = this;

            _(table.spec).forEach(function(spec){
                var oldFormatter = spec.headerFormatter;

                spec.headerFormatter = function(spec){
                    var html = _.isString(spec.title) ? spec.title : spec.name;
                    if(oldFormatter){
                        html = oldFormatter.call(this, spec);
                    }

                    if(spec.toggleable === false){
                        return html;
                    }

                    return getLinkHtml([spec.id]) + html;
                };
            });

            // NOTE: To work correctly with columnGrouper this plugin must be *after* that one in the array
            if(table.columnGrouper){
                setupColumnGroups(table.columnGrouper, table.spec);
            }

            table.$el.delegate('th a.removeColumn', 'click', function(e){
                e.preventDefault();

                var ids = $(e.target).data('ids');

                _([].concat(ids)).forEach(function(id){
                    var field = table.getField({id: id});
{'fraction_non_alphanumeric': 0.12630805948228382, 'fraction_numerical': 0.0, 'mean_word_length': 1.6382566585956417, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '480136', 'n_tokens_mistral': 1439, 'n_tokens_neox': 1353, 'n_words': 262}