{% load i18n static common %}
{% autoescape off %}
  <div id="{{ model_name }}_edit_form" style="{% block form_style %}padding: 10px;{% endblock %}">
    <form class="layui-form data-form" action="" method="post"  enctype="multipart/form-data">
      {% csrf_token %}
      {% with adminform.form as f %}
        <div class="layui-form-item">
          {% layui_inline f.line_notify_dept %}
        </div>
        <div class="layui-form-item">
          {% layui_inline f.include_sub_department %}
        </div>
        <div class="layui-form-item">
          {% layui_inline f.line_notify_token %}
        </div>
        <div class="layui-form-item">
          {% layui_inline f.message_type %}
        </div>
        <div class="layui-form-item" id="id_box_push_time">
          {% layui_inline f.push_time %}
        </div>
        <div class="layui-form-item">
          {% layui_inline f.message_head %}
        </div>
        <div class="layui-form-item">
          {% layui_inline f.message_tail %}
        </div>
        <div class="layui-form-item">
          {% layui_inline f.is_valid %}
        </div>
        <div class="layui-form-item">
          {% layui_inline f.remark %}
        </div>
      {% endwith %}
      <div class="layui-form-item">
        <div class="layui-input-inline ">
          <a href="javascript:void(0)" id="id_get_line_token" onclick="get_line_token()"
             style="color:blue">{% trans 'line_taken_btn' %}</a>
        </div>
        <script>
        function get_line_token() {
          var line_window = window.open("https://notify-bot.line.me/my/");
        }
        </script>
      </div>
    </form>
  </div>
  <script>
    $(function () {
      layui.use(['form', 'laydate'], function() {
        var form = layui.form;
        var laydate = layui.laydate;
        $("form.layui-form input.layui-time").each(function(){
            laydate.render({elem: this, type: 'time'});
        });
        form.on('select', function(data){
          if (data.value === "200"){
            $("#id_box_push_time").show();
          } else if (data.value === "100"){
            $("#id_box_push_time").hide();
          }
        });
        form.render();
      });
    });
    if ($("#id_message_type").val() !== "200"){
      $("#id_box_push_time").hide();
    }
  </script>
{% endautoescape %}