<commit_before>{% macro renderAvailableVariablesWidget(entityName, dependentFieldId) %}
    <script type="text/javascript">
        $(function() {
            'use strict';

            var availableVariables = {{ render(path('oro_api_get_emailtemplate_available_variables', { 'entityName': entityName }))}};

            new Oro.Email.VariablesUpdater.View({
                el:         $('#oro-email-available-variables'),
                template:   $('#available-variables-lists-template'),
                target:     $('#{{ dependentFieldId }}'),
                model:      new Oro.Email.VariablesUpdater.Variable(availableVariables)
            });
        })
    </script>

    <script type="text/template" id="available-variables-lists-template">
        <% if (userVars.length > 0) { %>
        <div>
            <h4>{{ 'Logged in user:'|trans }}</h4>
            <ul class="nav nav-list">
                <% _.each(userVars, function(variable, i) { %>
                    <li><a href="javascript:void(0);">{% verbatim %}{{ user.<%= variable %> }}{% endverbatim %}</a></li>
                <% }); %>
            </ul>
        </div>
        <% } %>
        <% if (entityVars.length > 0) { %>
        <div>
            <h4>{{ 'Related entity:'|trans }}</h4>
            <ul class="nav nav-list">
                <% _.each(entityVars, function(variable, i) { %>
                    <li><a href="javascript:void(0);">{% verbatim %}{{ entity.<%= variable %> }}{% endverbatim %}</a></li>
                <% }); %>
            </ul>
        </div>
        <% } %>
    </script>

    <div class="well well-small span5" id="oro-email-available-variables"></div>
{% endmacro %}

{% macro renderPreviewDialog(formName, title) %}
    <script type="text/javascript">
        $(function () {
            var showEmailPreviewDialog = function (el) {
                var iframe = $('<iframe />',
                        {
                            name: "preview-frame",
                            id: "preview-frame",
                            'class': "scrollable-container",
                            frameborder: 0,
                            marginwidth: 0,
                            marginheight: 0,
                            allowfullscreen: true,
                            width: "100%"
                        });

                var form = $('#{{ formName }}');
                var formAction = form.attr('action');

                form.bindFirst('submit', function(e) {
                    // prevent hash navigation form processing
                    new Oro.widget.DialogView({
                        el: $('<div id="inject-content"></div>'),
                        //el: iframe,
                        url: false,
                        dialogOptions: {
                            allowMaximize: true,
                            allowMinimize: true,
                            dblclick: 'maximize',
                            maximizedHeightDecreaseBy: 'minimize-bar',
                            minWidth: 600,
                            minHeight: 400,
                            title: $(el).attr('title')
                        }
                    }).render();

                    $('#inject-content').append(iframe);
                    form.attr('target', 'preview-frame');
                    form.attr('action', $(el).attr('href'));
                    e.stopImmediatePropagation();
                });<commit_msg>BAP-1255: Template preview   - adjust iframe width<commit_after>{% macro renderAvailableVariablesWidget(entityName, dependentFieldId) %}
    <script type="text/javascript">
        $(function() {
            'use strict';

            var availableVariables = {{ render(path('oro_api_get_emailtemplate_available_variables', { 'entityName': entityName }))}};

            new Oro.Email.VariablesUpdater.View({
                el:         $('#oro-email-available-variables'),
                template:   $('#available-variables-lists-template'),
                target:     $('#{{ dependentFieldId }}'),
                model:      new Oro.Email.VariablesUpdater.Variable(availableVariables)
            });
        })
    </script>

    <script type="text/template" id="available-variables-lists-template">
        <% if (userVars.length > 0) { %>
        <div>
            <h4>{{ 'Logged in user:'|trans }}</h4>
            <ul class="nav nav-list">
                <% _.each(userVars, function(variable, i) { %>
                    <li><a href="javascript:void(0);">{% verbatim %}{{ user.<%= variable %> }}{% endverbatim %}</a></li>
                <% }); %>
            </ul>
        </div>
        <% } %>
        <% if (entityVars.length > 0) { %>
        <div>
            <h4>{{ 'Related entity:'|trans }}</h4>
            <ul class="nav nav-list">
                <% _.each(entityVars, function(variable, i) { %>
                    <li><a href="javascript:void(0);">{% verbatim %}{{ entity.<%= variable %> }}{% endverbatim %}</a></li>
                <% }); %>
            </ul>
        </div>
        <% } %>
    </script>

    <div class="well well-small span5" id="oro-email-available-variables"></div>
{% endmacro %}

{% macro renderPreviewDialog(formName, title) %}
    <script type="text/javascript">
        $(function () {
            var showEmailPreviewDialog = function (el) {
                var iframe = $('<iframe />',
                        {
                            name: "preview-frame",
                            id: "preview-frame",
                            class: "scrollable-container",
                            frameborder: 0,
                            marginwidth: 0,
                            marginheight: 0,
                            allowfullscreen: true
                        });

                var form = $('#{{ formName }}');
                var formAction = form.attr('action');

                form.bindFirst('submit', function(e) {
                    var dialog = new Oro.widget.DialogView({
                        el: iframe,
                        url: false,
                        dialogOptions: {
                            allowMaximize: true,
                            allowMinimize: true,
                            dblclick: 'maximize',
                            maximizedHeightDecreaseBy: 'minimize-bar',
                            minWidth: 600,
                            minHeight: 400,
                            title: $(el).attr('title')
                        }
                    });
                    dialog.render();

                    var width = dialog.widget.parent('.ui-dialog').width() - 2*parseInt(dialog.widget.css('padding'));
                    dialog.widget.width(width);

                    $('#inject-content').append(iframe);
                    form.attr('target', 'preview-frame');
                    form.attr('action', $(el).attr('href'));

                    // prevent hash navigation form processing
                    e.stopImmediatePropagation();
                });
{'fraction_non_alphanumeric': 0.14674220963172804, 'fraction_numerical': 0.006232294617563739, 'mean_word_length': 1.2799483371004197, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 85, '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': '5393898', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1710, 'n_words': 319}