PageRenderTime 18ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/gallery-by-supsystic/src/GridGallery/Core/views/form.twig

https://gitlab.com/vovanduc/dainghia
Twig Template | 144 lines | 109 code | 35 blank | 0 comment | 18 complexity | a7001424b3b03b76059edcfac17f6be3 MD5 | raw file
  1{% macro open(method, action, attributes) %}
  2    <form method="{{ method|upper }}" {% if action is not empty %}action="{{ action }}"{% endif %}
  3    {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
  4{% endmacro %}
  5
  6{% macro close() %}
  7    </form>
  8{% endmacro %}
  9
 10{% macro show_tooltip(id) %}
 11
 12    {# Uncomment to enable tooptips: #}
 13    {% set title = tooltips[id] %}
 14
 15    {% if title is not empty %}
 16        <i class="fa fa-{{ tooltips_icon.icon|default('question') }} supsystic-tooltip"
 17           title="{{ title|raw }}"
 18           style="{% for property, value in tooltips_icon.style %}{{ property|trim }}:{{ value|trim }};{% endfor %}"></i>
 19    {% endif %}
 20
 21{% endmacro %}
 22
 23{% macro row(label, element, id, titleRow) %}
 24
 25    {% import _self as form %}
 26
 27    <tr>
 28        <th scope="row">
 29            {% if titleRow is not empty %}
 30                <h3 style="margin: 0 !important;">
 31                    {{ label }}
 32                    {{ form.show_tooltip(id) }}
 33                </h3>
 34            {% else %}
 35                <label {% if id is not empty %}id="label-{{ id }}" for="{{ id }}"{% endif %}>
 36                    {{ label }}
 37                    {{ form.show_tooltip(id) }}
 38                </label>
 39            {% endif %}
 40        </th>
 41        <td id="{{ id }}">
 42            {{ element|raw }}
 43        </td>
 44    </tr>
 45{% endmacro %}
 46
 47{% macro input(type = 'text', name, value, attributes) %}
 48    <input type="{{ type }}" name="{{ name }}" value="{{ value }}"
 49    {% for attribute, val in attributes %}
 50        {% if val is iterable %}
 51            {{ attribute }}="{% for attr, param in val %}{{ attr }}:{{ param }};{% endfor %}"
 52        {% else %}
 53            {{ attribute }}="{{ val }}"
 54        {% endif %}
 55    {% endfor %}
 56    />
 57{% endmacro %}
 58
 59{% macro text(name, value, attributes) %}
 60    {% import _self as form %}
 61
 62    {{ form.input('text', name, value, attributes) }}
 63{% endmacro %}
 64
 65{% macro password(name, value, attributes) %}
 66    {% import _self as form %}
 67
 68    {{ form.input('password', name, value, attributes) }}
 69{% endmacro %}
 70
 71{% macro button(name, value, attributes) %}
 72    {% import _self as form %}
 73
 74    {% if attributes.class is defined %}
 75        {% set attributes = attributes|merge({ 'class': attributes.class ~ ' button button-primary' }) %}
 76    {% endif %}
 77
 78    {{ form.input('button', name, value, attributes) }}
 79{% endmacro %}
 80
 81{% macro checkbox(name, value, attributes) %}
 82    {% import _self as form %}
 83
 84    {{ form.input('checkbox', name, value, attributes) }}
 85{% endmacro %}
 86
 87{% macro file(name, value, attributes) %}
 88    {% import _self as form %}
 89
 90    {{ form.input('file', name, value, attributes) }}
 91{% endmacro %}
 92
 93{% macro hidden(name, value, attributes) %}
 94    {% import _self as form %}
 95
 96    {{ form.input('hidden', name, value, attributes) }}
 97{% endmacro %}
 98
 99{% macro radio(name, value, attributes) %}
100    {% import _self as form %}
101
102    {{ form.input('radio', name, value, attributes) }}
103{% endmacro %}
104
105{% macro color(name, value, attributes) %}
106    {% import _self as form %}
107
108    {{ form.input('color', name, value, attributes) }}
109{% endmacro %}
110
111{% macro submit(name, value, attributes) %}
112    {% import _self as form %}
113
114    {% if attributes.class is defined %}
115        {% set attributes = attributes|merge({ 'class': attributes.class ~ ' button button-primary' }) %}
116    {% endif %}
117
118    {{ form.input('submit', name, value, attributes) }}
119{% endmacro %}
120
121{% macro select(name, options, selected, attributes) %}
122
123    <select name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
124    {% for value, text in options %}
125        <option value="{{ value }}" name = "{{ text|lower }}" {% if selected == value %}selected{% endif %}>{{ text }}</option>
126    {% endfor %}
127    </select>
128{% endmacro %}
129
130{% macro selectv(name, options, selected, attributes) %}
131
132    <select name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
133    {% for text in options %}
134        <option value="{{ text }}" name = "{{ text|lower }}" {% if selected == text %}selected{% endif %}>{{ text }}</option>
135    {% endfor %}
136    </select>
137{% endmacro %}
138
139{% macro span(name, text, attributes) %}
140
141    <span name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
142        {{ text|lower }}
143    </span>
144{% endmacro %}