vendor/sg/datatablesbundle/Resources/views/render/datetime.html.twig line 1

Open in your IDE?
  1. {##
  2.  # This file is part of the SgDatatablesBundle package.
  3.  #
  4.  # (c) stwe <https://github.com/stwe/DatatablesBundle>
  5.  #
  6.  # For the full copyright and license information, please view the LICENSE
  7.  # file that was distributed with this source code.
  8.  #}
  9. {%- set datetime_id_selector -%}
  10.     sg-datatables-{{ datatable_name }}-datetime-{{ row_id }}
  11. {%- endset -%}
  12. {%- set datetime_selector -%}
  13.     id="{{ datetime_id_selector }}"
  14. {%- endset -%}
  15. {% if column_class_editable_selector is defined %}
  16.     <div {{ datetime_selector }} class="{{ column_class_editable_selector }}" data-pk="{{ pk }}" {% if path is not same as(null) %}data-path="{{ path }}"{% endif %}></div>
  17. {% else %}
  18.     <div {{ datetime_selector }}>
  19.         {% if data is same as(null) and default_content is not same as(null) %}
  20.             {{ default_content }}
  21.         {% endif %}
  22.     </div>
  23. {% endif %}
  24. {% if data is not same as(null) %}
  25.     <script type="text/javascript">
  26.         $(function() {
  27.             moment.locale("{{ app.request.locale }}");
  28.             {% if timeago is same as(false) %}
  29.                 $("#{{ datetime_id_selector }}").html(moment.unix({{ data|date('U') }}).format("{{ date_format }}"));
  30.             {% else %}
  31.                 $("#{{ datetime_id_selector }}").html(moment.unix({{ data|date('U') }}).fromNow());
  32.             {% endif %}
  33.         });
  34.     </script>
  35. {% endif %}