{{ define "admin/custom_bottom_static" }}
<script>
    tinymce.init({
        selector: 'textarea#editor-preview',
        height: 300,
        language: 'ru',
        statusbar: false,
        promotion: false,
        plugins: "code",
        toolbar: 'code | bold italic underline forecolor | copy cut paste'
    });
    tinymce.init({
        selector: 'textarea#editor-text',
        height: 1000,
        language: 'ru',
        menubar: false,
        statusbar: false,
        promotion: false,
        plugins: 'code',
        toolbar: 'code | bold italic underline forecolor | copy cut paste | alignleft aligncenter alignjustify alignright | h1 h2 h3 h4 h5 h6'
    });
</script>
{{ end }}
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
    <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 border-bottom">
        <h3 class="h3">{{ .title }}</h3>
    </div>
    <form method="post" class="mb-5">
        <div class="row mb-3 mt-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">
                {{ trans .lang "admin_article_is_active" }}
            </label>
            <div class="col-sm-10">
                <div class="form-check form-switch pt-2">
                    <input class="form-check-input" type="checkbox" name="is_active" {{ if .form.IsActive }}checked{{ end }}>
                </div>
            </div>
        </div>
        <div class="row mb-3 mt-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">
                {{ trans .lang "admin_article_language" }}
            </label>
            <div class="col-sm-10">
                {{ $sLang := .form.Language }}
                {{ $langErr := index .errors "Language" }}
                <select name="language" class="form-select form-select-sm">
                    {{ range .languages }}
                        <option {{ if eq $sLang . }}selected{{ end }} value="{{ . }}">{{ . }}</option>
                    {{ end }}
                </select>
                {{ if $langErr }}
                <div class="invalid-feedback">
                    {{ $langErr }}
                </div>
                {{ end }}
            </div>
        </div>
        <div class="row mb-3 mt-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">
                {{ trans .lang "admin_article_title" }}
            </label>
            <div class="col-sm-10">
                {{ $titleErr := index .errors "Title" }}
                <input type="text" class="form-control form-control-sm {{ if $titleErr }}is-invalid{{ end }}" name="title" value="{{ .form.Title }}">
                {{ if $titleErr }}
                <div class="invalid-feedback">
                    {{ $titleErr }}
                </div>
                {{ end }}
            </div>
        </div>
        <div class="row mb-3 mt-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">
                {{ trans .lang "admin_article_image" }}
            </label>
            <div class="col-sm-10">
                {{ $imageErr := index .errors "Image" }}
                <input type="text" class="form-control form-control-sm {{ if $imageErr }}is-invalid{{ end }}" name="image" value="{{ .form.Image }}">
                {{ if $imageErr }}
                <div class="invalid-feedback">
                    {{ $imageErr }}
                </div>
                {{ end }}
            </div>
        </div>
        <div class="row mb-3 mt-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">
                URL
            </label>
            <div class="col-sm-10">
                {{ $urlErr := index .errors "URL" }}
                <input type="text" class="form-control form-control-sm {{ if $urlErr }}is-invalid{{ end }}" name="url" value="{{ .form.URL }}">
                {{ if $urlErr }}
                <div class="invalid-feedback">
                    {{ $urlErr }}
                </div>
                {{ end }}
            </div>
        </div>
        <div class="row mb-3 mt-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">
                {{ trans .lang "admin_article_pub_date" }}
            </label>
            <div class="col-sm-10">
                {{ $dateErr := index .errors "PublishTime" }}
                <input type="date" class="form-control form-control-sm {{ if $dateErr }}is-invalid{{ end }}" name="publish_time" value="{{ .form.PublishTime }}">
                {{ if $dateErr }}
                <div class="invalid-feedback">
                    {{ $dateErr }}
                </div>
                {{ end }}
            </div>
        </div>
        <div class="row mb-3 mt-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">
                {{ trans .lang "admin_preview_text" }}
            </label>
            <div class="col-sm-10">
                {{ $previewErr := index .errors "PreviewText" }}
                <textarea id="editor-preview" class="form-control form-control-sm {{ if $previewErr }}is-invalid{{ end }}" name="preview_text">{{ .form.PreviewText }}</textarea>
                {{ if $previewErr }}
                <div class="invalid-feedback">
                    {{ $previewErr }}
                </div>
                {{ end }}
            </div>
        </div>
        <div class="row mb-3 mt-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">
                {{ trans .lang "admin_text" }}
            </label>
            <div class="col-sm-10">
                {{ $textErr := index .errors "Text" }}
                <textarea id="editor-text" class="form-control form-control-sm {{ if $textErr }}is-invalid{{ end }}" name="text">{{ .form.Text }}</textarea>
                {{ if $textErr }}
                <div class="invalid-feedback">
                    {{ $textErr }}
                </div>
                {{ end }}
            </div>
        </div>
        <div class="row mb-3 mt-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">
                Meta keywords
            </label>
            <div class="col-sm-10">
                {{ $mkErr := index .errors "MetaKeywords" }}
                <input type="text" class="form-control form-control-sm {{ if $mkErr }}is-invalid{{ end }}" name="meta_keywords" value="{{ .form.MetaKeywords }}">
                {{ if $mkErr }}
                <div class="invalid-feedback">
                    {{ $mkErr }}
                </div>
                {{ end }}
            </div>
        </div>
        <div class="row mb-3 mt-3">
            <label class="col-sm-2 col-form-label col-form-label-sm">
                Meta description
            </label>
            <div class="col-sm-10">
                {{ $mdErr := index .errors "MetaDescription" }}
                <input type="text" class="form-control form-control-sm {{ if $mdErr }}is-invalid{{ end }}" name="meta_description" value="{{ .form.MetaDescription }}">
                {{ if $mdErr }}
                <div class="invalid-feedback">
                    {{ $mdErr }}
                </div>
                {{ end }}
            </div>
        </div>
        <div class="row mb-3 mt-3 border-bottom">
            <label class="col-sm-2 col-form-label col-form-label-sm">
                {{ trans .lang "admin_tags" }}
            </label>
            <div class="col-sm-10">
                {{ $tags := .form.ActiveTags }}
                {{ range .tags }}
                <div class="form-check">
                    <input class="form-check-input" type="checkbox" name="tag" value="{{ .ID }}" {{ if index $tags .ID }}checked{{ end }}>
                    <label class="form-check-label">
                        {{ .Tag }}
                    </label>
                </div>
                {{ end }}
            </div>
        </div>
        <a href="/admin" class="btn btn-sm btn-secondary">{{ trans .lang "admin_back" }}</a>
        {{ if .show_apply }}
            <button type="submit" class="btn btn-sm btn-primary" name="action" value="apply">
                {{ trans .lang "admin_apply_btn" }}
            </button>
        {{ end }}
        <button type="submit" class="btn btn-sm btn-primary" name="action" value="save">
            {{ trans .lang "admin_save_btn" }}
        </button>
    </form>
</main>