<commit_before>{#
 #
 # This file is part of the CSBill package.
 #
 # (c) <NAME> <<EMAIL>>
 #
 # For the full copyright and license information, please view the LICENSE
 # file that was distributed with this source code.
#}

{% use 'form_div_layout.html.twig' %}

{% block money_widget %}
{% spaceless %}
    <div class="input-{{ money_addon_class }}">{{ parent() }}</div>
{% endspaceless %}
{% endblock money_widget %}

{% block form_widget_compound %}
{% spaceless %}
    <div {{ block('widget_container_attributes') }}>
        <fieldset>
            {{ block('form_rows') }}
            {{ form_rest(form) }}
        </fieldset>
    </div>
{% endspaceless %}
{% endblock form_widget_compound %}

{% block widget_attributes %}
{% spaceless %}
    id="{{ id }}" name="{{ full_name }}"{% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} data-required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} data-pattern="{{ pattern }}"{% endif %}
    {% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %}
{% endspaceless %}
{% endblock widget_attributes %}

{% block form_row %}
{% spaceless %}
    <div class="control-group{{ errors|length > 0 ? ' error' : '' }} {{ form.vars.attr.class|default('') }}">

     {#
        {% if 'checkbox' in form.vars.types %}
            {{ form_widget(form) }}
            {{ form_label(form, label|default(null)) }}
        {% else %}
            {{ form_label(form, label|default(null)) }}
            {{ form_widget(form) }}
        {% endif %}
    #}

        {{ form_label(form, label|default(null)) }}
        {{ form_widget(form) }}

        {#
            If the child is a compound form, the errors are rendered inside
            the container. See also block form_rows.
        #}

        {% if not compound %}
            {{ form_errors(form) }}
        {% endif %}

        {% if help is defined %}
            <span class="help-{{ help_type }}"><small>{{ help|trans|nl2br }}</small></span>
        {% endif %}
    </div>
{% endspaceless %}
{% endblock form_row %}

{% block form_rows %}
{% spaceless %}
    {{ form_errors(form) }}
    {% for child in form %}
        {% if prototype is defined %}
            <div class="content">
        {% endif %}
        {{ form_row(child) }}
        {% if prototype is defined %}
            </div>
        {% endif %}
    {% endfor %}
{% endspaceless %}
{% endblock form_rows %}

{% block form_errors %}
    {% spaceless %}
        {% if errors|length > 0 %}
            <div class="{{ compound ? "alert alert-danger" : "help-block" }}">
                {% for error in errors %}
                    {{
                        error.messagePluralization is null
                            ? error.messageTemplate|trans(error.messageParameters, 'validators')
                            : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'validators')
                    }}
                    <br />
                {% endfor %}
            </div>
        {% endif %}
    {% endspaceless %}
{% endblock form_errors %}

{% block form_label %}
{% spaceless %}

    {% if label is empty %}
        {% set label = name|humanize %}
    {% endif %}

    {% if not compound %}
        {% if required %}
            {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
        {% endif %}

        {% set label_attr = label_attr|merge({'for': id}) %}
        <label class="control-label"{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ label|trans({}, translation_domain) }}</label>
    {% else %}
        {% if prototype is defined %}
            <legend><h2{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ label|trans({}, translation_domain) }}</h2></legend>
        {% endif %}
    {% endif %}
{% endspaceless %}
{% endblock form_label %}

{% block choice_widget_expanded %}
{% spaceless %}
    <div {{ block('widget_container_attributes') }}>
    {% for child in form %}
        <div class="{{ child.vars.block_prefixes|join(' ') }}">
            {{ form_widget(child) }}
            {{ form_label(child) }}
        </div>
    {% endfor %}
    </div>
{% endspaceless %}
{% endblock choice_widget_expanded %}

{% block percent_widget %}
{% spaceless %}
    {% set type = type|default('number') %}

    <div class="input-append">
        {{ block('form_widget_simple') }} <div class="add-on">%</div>
    </div>
{% endspaceless %}
{% endblock percent_widget %}

{% block collection_widget %}
{% spaceless %}
    <div class="form-collection">
        {% set attr = attr|merge({'class': 'child well' }) %}
        {{ parent() }}
    </div>

    <script type="text/javascript">$(function(){$('#{{ form.vars.id }}').formCollection({'label' : '{{ form.vars.label|default(form.vars.name)|humanize }}'});});</script>
{% endspaceless %}
{% endblock collection_widget %}

{% block image_upload_widget %}
    {% spaceless %}

    {{ block('form_widget_simple') }}

    <div id="{{ id }}-uploader"></div>

        <script type="text/javascript">
            {# TODO : trim all the whitespace #}
            {# TODO : move all this to an external js file #}
            $(function(){

                function uploadSuccess(file, data, resource)
                {
                    if(!_.isObject(data)) {
                        data = $.parseJSON(data);
                    }

                    $('#{{ id }}-uploader').hide();

                    var img = $('<img />').attr('src', '{{ asset("uploads") }}/' + data.file);
                    var a = $('<a />').attr('href', '#').addClass('thumbnail').html(img);
                    var close_img = $('<b />').html('X').addClass('close');
                    var close = $('<a />').attr({'href' : '#', 'title' : '{{ "Remove Image"|trans }}"', 'rel' : 'tooltip'}).addClass('pull-right').html(close_img);

                    close.on('click', function(evt){
                        evt.preventDefault();
                        var a = $(this);

                        a.parents('div.image-thumbnail-preview').remove();

                        $('#{{ id }}-uploader').show();
                        $("#{{ id }}").val('');
                    });

                    var li = $('<li />').addClass('span2').append(close).append(a);
                    var ul = $('<ul />').addClass('thumbnails').append(li);
                    var div = $('<div />').addClass('image-thumbnail-preview').html(ul);

                    $('#{{ id }}').val(data.file);

                    $('#{{ id }}-uploader-queue').html('');
                    $('#{{ id }}-uploader').after(div);
                }

                $('#{{ id }}').hide();
                $('#{{ id }}-uploader').uploadify({
                        "swf" : "{{ asset('swf/uploadify.swf') }}",
                        "uploader" : "{{ path("_image_upload") }}",
                        "formData" : {"sessionId" : "{{ sessionId }}"},
                        "buttonText" : "{{ "Select File"|trans }}",
                        "multi"        : false,
                        "onUploadSuccess" : uploadSuccess
                    });

                {% if value is not empty %}
                    uploadSuccess(null, {"file" : "{{ value }}"});
                {% endif %}
            });
        </script>
    {% endspaceless %}
{% endblock image_upload_widget %}
<commit_msg>[CoreBundle] Added widgets for contact form<commit_after>{#
 #
 # This file is part of the CSBill package.
 #
 # (c) <NAME> <<EMAIL>>
 #
 # For the full copyright and license information, please view the LICENSE
 # file that was distributed with this source code.
#}

{% use 'form_div_layout.html.twig' %}

{% block money_widget %}
{% spaceless %}
    <div class="input-{{ money_addon_class }}">{{ parent() }}</div>
{% endspaceless %}
{% endblock money_widget %}

{% block form_widget_compound %}
{% spaceless %}
    <div {{ block('widget_container_attributes') }}>
        <fieldset>
            {{ block('form_rows') }}
            {{ form_rest(form) }}
        </fieldset>
    </div>
{% endspaceless %}
{% endblock form_widget_compound %}

{% block widget_attributes %}
{% spaceless %}
    id="{{ id }}" name="{{ full_name }}"{% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} data-required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} data-pattern="{{ pattern }}"{% endif %}
    {% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %}
{% endspaceless %}
{% endblock widget_attributes %}

{% block form_row %}
{% spaceless %}
    <div class="control-group{{ errors|length > 0 ? ' error' : '' }} {{ form.vars.attr.class|default('') }}">

     {#
        {% if 'checkbox' in form.vars.types %}
            {{ form_widget(form) }}
            {{ form_label(form, label|default(null)) }}
        {% else %}
            {{ form_label(form, label|default(null)) }}
            {{ form_widget(form) }}
        {% endif %}
    #}

        {{ form_label(form, label|default(null)) }}
        {{ form_widget(form) }}

        {#
            If the child is a compound form, the errors are rendered inside
            the container. See also block form_rows.
        #}

        {% if not compound %}
            {{ form_errors(form) }}
        {% endif %}

        {% if help is defined %}
            <span class="help-{{ help_type }}"><small>{{ help|trans|nl2br }}</small></span>
        {% endif %}
    </div>
{% endspaceless %}
{% endblock form_row %}

{% block form_rows %}
{% spaceless %}
    {{ form_errors(form) }}
    {% for child in form %}
        {% if prototype is defined %}
            <div class="content">
        {% endif %}
        {{ form_row(child) }}
        {% if prototype is defined %}
            </div>
        {% endif %}
    {% endfor %}
{% endspaceless %}
{% endblock form_rows %}

{% block form_errors %}
    {% spaceless %}
        {% if errors|length > 0 %}
            <div class="{{ compound ? "alert alert-danger" : "help-block" }}">
                {% for error in errors %}
                    {{
                        error.messagePluralization is null
                            ? error.messageTemplate|trans(error.messageParameters, 'validators')
                            : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'validators')
                    }}
                    <br />
                {% endfor %}
            </div>
        {% endif %}
    {% endspaceless %}
{% endblock form_errors %}

{% block form_label %}
{% spaceless %}

    {% if label is empty %}
        {% set label = name|humanize %}
    {% endif %}

    {% if not compound %}
        {% if required %}
            {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
        {% endif %}

        {% set label_attr = label_attr|merge({'for': id}) %}
        <label class="control-label"{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ label|trans({}, translation_domain) }}</label>
    {% else %}
        {% if prototype is defined %}

                <legend><h2{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ label|trans({}, translation_domain) }}</h2></legend>

        {% endif %}
    {% endif %}
{% endspaceless %}
{% endblock form_label %}

{% block choice_widget_expanded %}
{% spaceless %}
    <div {{ block('widget_container_attributes') }}>
    {% for child in form %}
        <div class="{{ child.vars.block_prefixes|join(' ') }}">
            {{ form_widget(child) }}
            {{ form_label(child) }}
        </div>
    {% endfor %}
    </div>
{% endspaceless %}
{% endblock choice_widget_expanded %}

{% block percent_widget %}
{% spaceless %}
    {% set type = type|default('number') %}

    <div class="input-append">
        {{ block('form_widget_simple') }} <div class="add-on">%</div>
    </div>
{% endspaceless %}
{% endblock percent_widget %}

{% block collection_widget %}
{% spaceless %}
    <div class="form-collection">
        {% set attr = attr|merge({'class': '`child' }) %}
        {{ parent() }}
    </div>

    <script type="text/javascript">$(function(){$('#{{ form.vars.id }}').formCollection({ {% if prototype_name is defined %}'field' : '{{ prototype_name }}', {% endif %}'label' : '{{ form.vars.label|default(form.vars.name)|humanize }}'});});</script>
{% endspaceless %}
{% endblock collection_widget %}

{% block image_upload_widget %}
    {% spaceless %}

    {{ block('form_widget_simple') }}

    <div id="{{ id }}-uploader"></div>

        <script type="text/javascript">
            {# TODO : trim all the whitespace #}
            {# TODO : move all this to an external js file #}
            $(function(){

                function uploadSuccess(file, data, resource)
                {
                    if(!_.isObject(data)) {
                        data = $.parseJSON(data);
                    }

                    $('#{{ id }}-uploader').hide();

                    var img = $('<img />').attr('src', '{{ asset("uploads") }}/' + data.file);
                    var a = $('<a />').attr('href', '#').addClass('thumbnail').html(img);
                    var close_img = $('<b />').html('X').addClass('close');
                    var close = $('<a />').attr({'href' : '#', 'title' : '{{ "Remove Image"|trans }}"', 'rel' : 'tooltip'}).addClass('pull-right').html(close_img);

                    close.on('click', function(evt){
                        evt.preventDefault();
                        var a = $(this);

                        a.parents('div.image-thumbnail-preview').remove();

                        $('#{{ id }}-uploader').show();
                        $("#{{ id }}").val('');
                    });

                    var li = $('<li />').addClass('span2').append(close).append(a);
                    var ul = $('<ul />').addClass('thumbnails').append(li);
                    var div = $('<div />').addClass('image-thumbnail-preview').html(ul);

                    $('#{{ id }}').val(data.file);

                    $('#{{ id }}-uploader-queue').html('');
                    $('#{{ id }}-uploader').after(div);
                }

                $('#{{ id }}').hide();
                $('#{{ id }}-uploader').uploadify({
                        "swf" : "{{ asset('swf/uploadify.swf') }}",
                        "uploader" : "{{ path("_image_upload") }}",
                        "formData" : {"sessionId" : "{{ sessionId }}"},
                        "buttonText" : "{{ "Select File"|trans }}",
                        "multi"        : false,
                        "onUploadSuccess" : uploadSuccess
                    });

                {% if value is not empty %}
                    uploadSuccess(null, {"file" : "{{ value }}"});
                {% endif %}
            });
        </script>
    {% endspaceless %}
{% endblock image_upload_widget %}

{% block contact_detail_widget %}
    {% include "CSBillClientBundle:Form:contact_details.html.twig" %}
{% endblock contact_detail_widget %}

{% block contact_widget %}
    {% include "CSBillClientBundle:Form:contacts.html.twig" %}
{% endblock contact_widget %}
{'fraction_non_alphanumeric': 0.1922735346358792, 'fraction_numerical': 0.0007612281146917026, 'mean_word_length': 2.0689118162351567, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 105, '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': '3869889', 'n_tokens_mistral': 4929, 'n_tokens_neox': 4356, 'n_words': 946}