argue-2.0.0-alpha4/themes/argue_base/templates/rate/rate-template-yesno.html.twig

themes/argue_base/templates/rate/rate-template-yesno.html.twig
{#
/**
 * @file
 * Default theme implementation for yes/no voting display.
 *
 * Available variables:
 * - widget_attributes: Attributes for outer div.
 * - yes_li_attributes: Attributes for yes li.
 * - yes_attributes: Attributes for yes div or link.
 * - up_votes: Number of up/yes votes.
 * - up_url: Url to vote yes/up.
 * - no_li_attributes: Attributes for no li.
 * - no_attributes: Attributes for no div or link.
 * - score_attributes: Attributes for vote total div.
 * - down_votes: Number of down/no votes.
 * - down_url: Url to vote no/down.
 * - undo: Link to undo placed vote.
 * - undo_attributes: Attributes for undo div.
 * - info_description: Extra textual info to display.
 *
 * @ingroup themeable
 */
#}
{% set btn_class = [
  'button',
  'button--extrasmall',
] %}

{% set my_vote = 0 %}

{% for vote in votes %}
  {% if vote == '1' %}
    {% set yes_li_attributes = yes_li_attributes.addClass('button--primary') %}
    {% set my_vote = 'yes' %}
  {% elseif vote == '-1' %}
    {% set no_li_attributes = no_li_attributes.addClass('button--primary') %}
    {% set my_vote = 'no' %}
  {% endif %}
{% endfor %}
{% set undo_title = 'Undo your decision.'|t %}

<div{{ widget_attributes }}>
  <div class="rate-widget-yesno--actions" role="grid">
    {% if not can_vote or (has_voted and my_vote != 'yes') %}
      <div{{ yes_li_attributes.addClass(btn_class, 'is-disabled', yes_li_classes).setAttribute('role', 'row') }}>
        <span class="argue-icon">user_confirm</span>
        {{ up_votes }}
      </div>
    {% elseif (has_voted and my_vote == 'yes') %}
      <a href="{{ undo.url|render }}" {{ yes_li_attributes.addClass(btn_class, 'rate-undo', 'use-ajax', yes_li_classes).setAttribute('title', undo_title) }}>
        <span class="argue-icon icon--lead">user_confirm</span>
        {{ up_votes }}
        <span class="argue-icon icon--trail" aria-hidden="true">clear</span>
      </a>
    {% else %}
      <a href="{{ up_url }}" {{ yes_li_attributes.addClass(btn_class, 'button--primary', 'rate-up', 'use-ajax', yes_li_classes).setAttribute('role', 'row') }}>
        <span class="argue-icon icon--lead">user_confirm</span>
        {{ up_votes }}
      </a>
    {% endif %}


    {% if not can_vote or (has_voted and my_vote != 'no') %}
      <div{{ no_li_attributes.addClass(btn_class, 'is-disabled', no_li_classes).setAttribute('role', 'row') }}>
        <span class="argue-icon icon--lead">user_decline</span>
        {{ down_votes }}
      </div>
    {% elseif (has_voted and my_vote == 'no') %}
      <a href="{{ undo.url|render }}" {{ no_li_attributes.addClass(btn_class, 'rate-undo', 'use-ajax', no_li_classes).setAttribute('role', 'row').setAttribute('title', undo_title) }}>
        <span class="argue-icon icon--lead">user_decline</span>
        {{ down_votes }}
        <span class="argue-icon icon--trail">clear</span>
      </a>
    {% else %}
      <a href="{{ down_url }}"{{ no_li_attributes.addClass(btn_class, 'button--primary', 'rate-down', 'use-ajax', no_li_classes).setAttribute('role', 'row') }}>
        <span class="argue-icon icon--lead">user_decline</span>
        {{ down_votes }}
      </a>
    {% endif %}
  </div>
</div>

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc