/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. {% macro close() %}
  6. </form>
  7. {% endmacro %}
  8. {% macro show_tooltip(id) %}
  9. {# Uncomment to enable tooptips: #}
  10. {% set title = tooltips[id] %}
  11. {% if title is not empty %}
  12. <i class="fa fa-{{ tooltips_icon.icon|default('question') }} supsystic-tooltip"
  13. title="{{ title|raw }}"
  14. style="{% for property, value in tooltips_icon.style %}{{ property|trim }}:{{ value|trim }};{% endfor %}"></i>
  15. {% endif %}
  16. {% endmacro %}
  17. {% macro row(label, element, id, titleRow) %}
  18. {% import _self as form %}
  19. <tr>
  20. <th scope="row">
  21. {% if titleRow is not empty %}
  22. <h3 style="margin: 0 !important;">
  23. {{ label }}
  24. {{ form.show_tooltip(id) }}
  25. </h3>
  26. {% else %}
  27. <label {% if id is not empty %}id="label-{{ id }}" for="{{ id }}"{% endif %}>
  28. {{ label }}
  29. {{ form.show_tooltip(id) }}
  30. </label>
  31. {% endif %}
  32. </th>
  33. <td id="{{ id }}">
  34. {{ element|raw }}
  35. </td>
  36. </tr>
  37. {% endmacro %}
  38. {% macro input(type = 'text', name, value, attributes) %}
  39. <input type="{{ type }}" name="{{ name }}" value="{{ value }}"
  40. {% for attribute, val in attributes %}
  41. {% if val is iterable %}
  42. {{ attribute }}="{% for attr, param in val %}{{ attr }}:{{ param }};{% endfor %}"
  43. {% else %}
  44. {{ attribute }}="{{ val }}"
  45. {% endif %}
  46. {% endfor %}
  47. />
  48. {% endmacro %}
  49. {% macro text(name, value, attributes) %}
  50. {% import _self as form %}
  51. {{ form.input('text', name, value, attributes) }}
  52. {% endmacro %}
  53. {% macro password(name, value, attributes) %}
  54. {% import _self as form %}
  55. {{ form.input('password', name, value, attributes) }}
  56. {% endmacro %}
  57. {% macro button(name, value, attributes) %}
  58. {% import _self as form %}
  59. {% if attributes.class is defined %}
  60. {% set attributes = attributes|merge({ 'class': attributes.class ~ ' button button-primary' }) %}
  61. {% endif %}
  62. {{ form.input('button', name, value, attributes) }}
  63. {% endmacro %}
  64. {% macro checkbox(name, value, attributes) %}
  65. {% import _self as form %}
  66. {{ form.input('checkbox', name, value, attributes) }}
  67. {% endmacro %}
  68. {% macro file(name, value, attributes) %}
  69. {% import _self as form %}
  70. {{ form.input('file', name, value, attributes) }}
  71. {% endmacro %}
  72. {% macro hidden(name, value, attributes) %}
  73. {% import _self as form %}
  74. {{ form.input('hidden', name, value, attributes) }}
  75. {% endmacro %}
  76. {% macro radio(name, value, attributes) %}
  77. {% import _self as form %}
  78. {{ form.input('radio', name, value, attributes) }}
  79. {% endmacro %}
  80. {% macro color(name, value, attributes) %}
  81. {% import _self as form %}
  82. {{ form.input('color', name, value, attributes) }}
  83. {% endmacro %}
  84. {% macro submit(name, value, attributes) %}
  85. {% import _self as form %}
  86. {% if attributes.class is defined %}
  87. {% set attributes = attributes|merge({ 'class': attributes.class ~ ' button button-primary' }) %}
  88. {% endif %}
  89. {{ form.input('submit', name, value, attributes) }}
  90. {% endmacro %}
  91. {% macro select(name, options, selected, attributes) %}
  92. <select name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
  93. {% for value, text in options %}
  94. <option value="{{ value }}" name = "{{ text|lower }}" {% if selected == value %}selected{% endif %}>{{ text }}</option>
  95. {% endfor %}
  96. </select>
  97. {% endmacro %}
  98. {% macro selectv(name, options, selected, attributes) %}
  99. <select name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
  100. {% for text in options %}
  101. <option value="{{ text }}" name = "{{ text|lower }}" {% if selected == text %}selected{% endif %}>{{ text }}</option>
  102. {% endfor %}
  103. </select>
  104. {% endmacro %}
  105. {% macro span(name, text, attributes) %}
  106. <span name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
  107. {{ text|lower }}
  108. </span>
  109. {% endmacro %}