<commit_before>/*==================================================
 *  Exhibit.ListFacet classic theme
 *==================================================
 */
 
Exhibit.ListFacet.theme = new Object();

Exhibit.ListFacet.theme.constructFacetFrame = function(
    exhibit,
    div,
    facetLabel,
    groupable,
    grouped,
    onGroup, 
    onCollapseAll, 
    onExpandAll, 
    onClearAllSelections,
    classNames
) {
    var l10n = Exhibit.ListFacet.l10n;

    var className = "exhibit-facet-frame";
    if (classNames && classNames.frame) {
        className += " " + classNames.frame;
    }

    var template = {
        elmt:       div,
        className:  className,
        style:      { height: "1px" },
        children: [
            {   tag:        "div",
                className:  "exhibit-facet",
                field:      "innerFacetDiv",
                children: [
                    {   tag:        "div",
                        className:  "exhibit-facet-header",
                        children: [ 
                            {   tag:        "div",
                                className:  "exhibit-facet-header-filterControl",
                                field:      "clearSelectionsDiv",
                                title:      l10n.clearSelectionsTooltip,
                                children:   [
                                    "",
                                    {   elmt: Exhibit.Theme.createTranslucentImage(document,
                                            "images/black-check-no-border.png")
                                    }
                                ]
                            },
                            {   tag:        "span",
                                className:  "exhibit-facet-header-title",
                                children:   [ facetLabel ]
                            },
                            {   tag:        "span",
                                className:  "exhibit-facet-header-details",
                                children:   []
                            }
                        ]
                    },
                    {   tag:        "div",
                        className:  "exhibit-facet-body-frame",
                        children: [
                            {   tag:        "div",
                                className:  "exhibit-facet-body",
                                field:      "valuesContainer"
                            }
                        ]
                    },
                    {   tag:        "div",
                        className:  "exhibit-facet-footer",
                        style:      { display: groupable ? "block" : "none" },
                        children: [
                            {   elmt:  exhibit.makeActionLink(l10n.groupByLink, onGroup),
                                field: "groupLink"
                            },
                            {   tag:    "span",
                                field:  "groupControlsSpan",
                                style:  { display: grouped ? "inline" : "none" },
                                children: [
                                    " | ",
                                    {   elmt:  exhibit.makeActionLink(l10n.collapseLink, onCollapseAll),
                                        field: "collapseLink"
                                    },
                                    " | ",
                                    {   elmt:  exhibit.makeActionLink(l10n.expandLink, onExpandAll),
                                        field: "expandLink"
                                    }
                                ]
                            }
                        ]
                    },
                    {   tag: "div",
                        className: "exhibit-facet-resizer",
                        field: "resizerDiv",
                        children: [
                            {   elmt: Exhibit.Theme.createTranslucentImage(document,
                                    "images/down-arrow.png")
                            }
                        ]
                    }
                ]
            }
        ]
    };
    
    var dom = SimileAjax.DOM.createDOMFromTemplate(document, template);
    
    dom.setSelectionCount = function(count) {
        this.clearSelectionsDiv.firstChild.nodeValue = count;
        this.innerFacetDiv.className = count > 0 ? 
            "exhibit-facet exhibit-facet-hasSelection" : "exhibit-facet";
    };
    dom.setGroupControlsVisible = function(visible) {
        this.groupControlsSpan.style.display = visible ? "inline" : "none";
    };
    dom.open = function() {
        var facetDiv = div.firstChild;
        var f = function(current, step) {
            if (step == 0) {
                div.style.overflow = "visible";
                div.style.opacity = 1;
                div.style.height = "";
            } else {
                var height = facetDiv.offsetHeight;
                div.style.height = Math.floor(height * current / 100) + "px";
                div.style.opacity = Math.round(current / 10) / 10;
            }
        };
        SimileAjax.Graphics.createAnimation(f, 0, 100, 300).run();
    };
    dom.close = function() {
        var parentNode = div.parentNode;
        var height = div.offsetHeight;
        div.style.overflow = "hidden";
        
        var f = function(current, step) {
            if (step == 0) {
                parentNode.removeChild(div);
            } else {
                div.style.height = Math.floor(height * current / 100) + "px";
                div.style.opacity = Math.round(current / 10) / 10;
            }
        };
        SimileAjax.Graphics.createAnimation(f, 100, 0, 500).run();
    };
    
    SimileAjax.WindowManager.registerEvent(dom.clearSelectionsDiv, "click", onClearAllSelections);
    SimileAjax.WindowManager.registerForDragging(
        dom.resizerDiv,
        {   onDragStart: function() {
                this._height = dom.valuesContainer.offsetHeight;
            },
            onDragBy: function(diffX, diffY) {
                this._height += diffY;
                dom.valuesContainer.style.height = Math.max(50, this._height) + "px";
            },
            onDragEnd: function() {
            }
        }
    );
    
    return dom;
};

Exhibit.ListFacet.theme.constructFacetItem = function(
    exhibit,
    label, 
    count, 
    level, 
    selected, 
    hasChildren, 
    expanded,
    onSelect
) {
    var l10n = Exhibit.ListFacet.l10n;
    
    var classes = [ "exhibit-facet-value" ];
    if (selected) {
        classes.push("exhibit-facet-value-selected");
    }<commit_msg>Allow resizing facets with a max-height property set from CSS, even beyond that size.<commit_after>/*==================================================
 *  Exhibit.ListFacet classic theme
 *==================================================
 */
 
Exhibit.ListFacet.theme = new Object();

Exhibit.ListFacet.theme.constructFacetFrame = function(
    exhibit,
    div,
    facetLabel,
    groupable,
    grouped,
    onGroup, 
    onCollapseAll, 
    onExpandAll, 
    onClearAllSelections,
    classNames
) {
    var l10n = Exhibit.ListFacet.l10n;

    var className = "exhibit-facet-frame";
    if (classNames && classNames.frame) {
        className += " " + classNames.frame;
    }

    var template = {
        elmt:       div,
        className:  className,
        style:      { height: "1px" },
        children: [
            {   tag:        "div",
                className:  "exhibit-facet",
                field:      "innerFacetDiv",
                children: [
                    {   tag:        "div",
                        className:  "exhibit-facet-header",
                        children: [ 
                            {   tag:        "div",
                                className:  "exhibit-facet-header-filterControl",
                                field:      "clearSelectionsDiv",
                                title:      l10n.clearSelectionsTooltip,
                                children:   [
                                    "",
                                    {   elmt: Exhibit.Theme.createTranslucentImage(document,
                                            "images/black-check-no-border.png")
                                    }
                                ]
                            },
                            {   tag:        "span",
                                className:  "exhibit-facet-header-title",
                                children:   [ facetLabel ]
                            },
                            {   tag:        "span",
                                className:  "exhibit-facet-header-details",
                                children:   []
                            }
                        ]
                    },
                    {   tag:        "div",
                        className:  "exhibit-facet-body-frame",
                        children: [
                            {   tag:        "div",
                                className:  "exhibit-facet-body",
                                field:      "valuesContainer"
                            }
                        ]
                    },
                    {   tag:        "div",
                        className:  "exhibit-facet-footer",
                        style:      { display: groupable ? "block" : "none" },
                        children: [
                            {   elmt:  exhibit.makeActionLink(l10n.groupByLink, onGroup),
                                field: "groupLink"
                            },
                            {   tag:    "span",
                                field:  "groupControlsSpan",
                                style:  { display: grouped ? "inline" : "none" },
                                children: [
                                    " | ",
                                    {   elmt:  exhibit.makeActionLink(l10n.collapseLink, onCollapseAll),
                                        field: "collapseLink"
                                    },
                                    " | ",
                                    {   elmt:  exhibit.makeActionLink(l10n.expandLink, onExpandAll),
                                        field: "expandLink"
                                    }
                                ]
                            }
                        ]
                    },
                    {   tag: "div",
                        className: "exhibit-facet-resizer",
                        field: "resizerDiv",
                        children: [
                            {   elmt: Exhibit.Theme.createTranslucentImage(document,
                                    "images/down-arrow.png")
                            }
                        ]
                    }
                ]
            }
        ]
    };
    
    var dom = SimileAjax.DOM.createDOMFromTemplate(document, template);
    
    dom.setSelectionCount = function(count) {
        this.clearSelectionsDiv.firstChild.nodeValue = count;
        this.innerFacetDiv.className = count > 0 ? 
            "exhibit-facet exhibit-facet-hasSelection" : "exhibit-facet";
    };
    dom.setGroupControlsVisible = function(visible) {
        this.groupControlsSpan.style.display = visible ? "inline" : "none";
    };
    dom.open = function() {
        var facetDiv = div.firstChild;
        var f = function(current, step) {
            if (step == 0) {
                div.style.overflow = "visible";
                div.style.opacity = 1;
                div.style.height = "";
            } else {
                var height = facetDiv.offsetHeight;
                div.style.height = Math.floor(height * current / 100) + "px";
                div.style.opacity = Math.round(current / 10) / 10;
            }
        };
        SimileAjax.Graphics.createAnimation(f, 0, 100, 300).run();
    };
    dom.close = function() {
        var parentNode = div.parentNode;
        var height = div.offsetHeight;
        div.style.overflow = "hidden";
        
        var f = function(current, step) {
            if (step == 0) {
                parentNode.removeChild(div);
            } else {
                div.style.height = Math.floor(height * current / 100) + "px";
                div.style.opacity = Math.round(current / 10) / 10;
            }
        };
        SimileAjax.Graphics.createAnimation(f, 100, 0, 500).run();
    };
    
    SimileAjax.WindowManager.registerEvent(dom.clearSelectionsDiv, "click", onClearAllSelections);
    SimileAjax.WindowManager.registerForDragging(
        dom.resizerDiv,
        {   onDragStart: function() {
                this._height = dom.valuesContainer.offsetHeight;
            },
            onDragBy: function(diffX, diffY) {
                this._height += diffY;
		var h = Math.max(50, this._height) + "px";
                dom.valuesContainer.style.height = h;
                dom.valuesContainer.style.maxHeight = h;
            },
            onDragEnd: function() {
            }
        }
    );
    
    return dom;
};

Exhibit.ListFacet.theme.constructFacetItem = function(
    exhibit,
    label, 
    count, 
    level, 
    selected, 
    hasChildren, 
    expanded,
    onSelect
) {
    var l10n = Exhibit.ListFacet.l10n;
    
    var classes = [ "exhibit-facet-value" ];
    if (selected) {
        classes.push("exhibit-facet-value-selected");
    }
{'fraction_non_alphanumeric': 0.11022693781314472, 'fraction_numerical': 0.007515473032714412, 'mean_word_length': 0.9733934283221867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4667241', 'n_tokens_mistral': 3562, 'n_tokens_neox': 3265, 'n_words': 534}