<commit_before>{% from "shuup/xtheme/admin/macros.jinja" import theme_table %}

<input type="hidden" name="theme-activate" value="{{ form_def.context["current_theme"].identifier }}">
{{ theme_table(form_def.context["theme_classes"], form_def.context["current_theme"], "chooseTheme(this)", True) }}

<script>
function toggleRowState($tr) {
    var $title = $tr.find(".title");
    var $action = $($tr.find("td")[1]);
    if($tr.hasClass("active-row")) {
        $title.replaceWith("<span class='title'>" + $title.text() + "</span>");
    } else {
        $title.replaceWith("<strong class='title'>" + $title.text() + "</strong>");
    }
    $action.find("button").toggleClass("hidden");
    $action.find(".active").toggleClass("hidden");
    $tr.toggleClass("active-row");
}

function chooseTheme(button) {
    $(".wizard-pane.active form input[name='theme-activate']").val(button.value);
    toggleRowState($(".theme-table .active-row"));
    toggleRowState($(button).parents("tr"));
    // actual submission happens when user clicks next in wizard
}
</script><commit_msg>Xtheme: Fix wizard theme selection<commit_after>{% from "shuup/xtheme/admin/macros.jinja" import theme_table %}

<input type="hidden" name="theme-activate" value="{{ form_def.context["current_theme"].identifier }}">
{{ theme_table(form_def.context["theme_classes"], form_def.context["current_theme"], "chooseTheme(this)", True) }}

<script>
function toggleRowState($tr) {
    var $title = $tr.find(".title");
    var $action = $($tr.find("td")[2]);
    if($tr.hasClass("active-row")) {
        $title.replaceWith("<span class='title'>" + $title.text() + "</span>");
    } else {
        $title.replaceWith("<strong class='title'>" + $title.text() + "</strong>");
    }
    $action.find("button").toggleClass("hidden");
    $action.find(".active").toggleClass("hidden");
    $tr.toggleClass("active-row");
}

function chooseTheme(button) {
    $(".wizard-pane.active form input[name='theme-activate']").val(button.value);
    toggleRowState($(".theme-table .active-row"));
    toggleRowState($(button).parents("tr"));
    // actual submission happens when user clicks next in wizard
}
</script>
{'fraction_non_alphanumeric': 0.21478060046189376, 'fraction_numerical': 0.0009237875288683603, 'mean_word_length': 4.934246575342466, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4225814', 'n_tokens_mistral': 689, 'n_tokens_neox': 677, 'n_words': 111}