@extends('admin.master')

@section('top')
<div class="top-breadcrumb pull-left">
    <h5>编辑导航</h5>
    <a class="btn btn-xs btn-default goback" onclick="javascript:history.go(-1);">
        <i class="iconfont icon-back-copy"></i><span>返回</span>
    </a>
</div>
@endsection

@section('content')
{!! Form::model($category, ['route' => ['admin.nav.update', $category->id], 'method'=>'put', 'class'=>'form-horizontal form-detail']) !!}
 <div class="tab-content">
    <div role="tabpanel" class="tab-pane active" id="home">
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane active" id="language-{{ $managerLang }}">
                <div class="form-group">
                    <label class="col-sm-2 control-label label-width">上级分类：</label>
                    <div class="col-sm-5">
                        {!! Form::select('parent_id', ['请选择'] + $categoryNest, null, ['class'=>'form-control', 'id'=>'select-cate']) !!}
                    </div>
                </div>
                <div class="form-group {{ $managerLang == config('setting.lang') ? 'form-item-required' : ''}}">
                    <label class="col-sm-2 control-label label-width">名称：</label>
                    <div class="col-sm-5">
                        {!! Form::text("description[{$managerLang}][cname]", isset($descriptions[$managerLang]) ? $descriptions[$managerLang][0]->cname : '', ['class'=>'form-control']) !!}
                    </div>
                </div>
                <div class="form-group form-model">
                  <label class="col-sm-2 control-label label-width">所属模型：</label>
                  <div class="col-sm-5">
                    {!! Form::select('content_model', ['' => '请选择'] + config('system.content_models'), null, ['class'=>'form-control', 'id'=>'select-model']) !!}
                  </div>
                </div>
                <div class="form-group form-column {{ $category->content_model ? '' : 'hidden' }}">
                  <label class="col-sm-2 control-label label-width">所属栏目：</label>
                  <div class="col-sm-5">
                    {!! Form::select('content_model_id', $category->content_model == 'page' ? $columns : ['' => '请选择'] + $columns, 'id-' . $category->content_model_id, ['class'=>'form-control', 'id'=>'select-column']) !!}
                  </div>
                </div>
                <div class="form-group form-item-required form-link {{ $category->content_model ? 'hidden' : '' }}">
                    <label class="col-sm-2 control-label label-width">链接：</label>
                    <div class="col-sm-5">
                        {!! Form::text('linkurl', null, ['class'=>'form-control']) !!}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label label-width">摘要：</label>
                    <div class="col-sm-5">
                        {!! Form::textarea("description[{$managerLang}][summary]", isset($descriptions[$managerLang]) ? $descriptions[$managerLang][0]->summary : '', ['class'=>'form-control', 'rows'=>5]) !!}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label label-width">详细内容：</label>
                    <div class="col-sm-10">
                        {!! Form::textarea("description[{$managerLang}][content]", isset($descriptions[$managerLang]) ? $descriptions[$managerLang][0]->content : '', ['id'=>"editor-{$managerLang}", 'class'=>'len-full']) !!}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label label-width">图片：</label>
                    <div class="col-sm-5">
                        <div class="upload-wrap" data-name="description[{{ $managerLang }}][imgs][]">
							<div class="upload-wrap-btn">
								<span class="btn btn-default" data-toggle="modal" data-target="#media-dialog-modal">媒体上传</span>
								<span class="text-muted pl-10">(允许上传的媒体类型：jpg、gif、png)</span>
							</div>
							<ul id="picfram" class="upload-wrap-lists attachments clearfix">
								@if(isset($descriptions[$managerLang]) && $descriptions[$managerLang][0]->imgs)
									@foreach ($descriptions[$managerLang][0]->imgs as $value)
										<li class="thumbnail thumb-imgs" data-img="{{ $value }}">
											<input name="description[{{ $managerLang }}][imgs][]" value="{{ $value }}" type="hidden" class="uploadfiles-input">
											<a class="thumbnail-img"><img src="{{ url($value) }}"></a>
											<a class="thumbnail-remove" href="javascript:;">删除</a>
										</li>
									@endforeach
								@endif
							</ul>
						</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label label-width">排序：</label>
                    <div class="col-sm-5">
                        {!! Form::number('orders', null, ['class'=>'form-control']) !!}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label label-width">导航属性：</label>
                    <div class="col-sm-5">
                        <div class="pretty-box">
                            <div class="pretty p-default p-round p-smooth">
                                {!! Form::radio('types', 1, null) !!}
                                <div class="state p-success-o"><label>导航栏目</label></div>
                            </div>
                            <div class="pretty p-default p-round p-smooth">
                                {!! Form::radio('types', 2, null) !!}
                                <div class="state p-success-o"><label>网站单页</label></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label label-width">状态：</label>
                    <div class="col-sm-5">
                        <div class="pretty-box">
                            <div class="pretty p-default p-round p-smooth">
                                {!! Form::radio('flag', 1, null) !!}
                                <div class="state p-success-o"><label>显示</label></div>
                            </div>
                            <div class="pretty p-default p-round p-smooth">
                                {!! Form::radio('flag', 0, null) !!}
                                <div class="state p-success-o"><label>不显示</label></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group form-group-line"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label label-width">标题：</label>
                    <div class="col-sm-5">
                        {!! Form::text("description[{$managerLang}][seo_title]", isset($descriptions[$managerLang]) ? $descriptions[$managerLang][0]->seo_title : '', ['class'=>'form-control']) !!}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label label-width">关键词：</label>
                    <div class="col-sm-5">
                        {!! Form::text("description[{$managerLang}][seo_keywords]", isset($descriptions[$managerLang]) ? $descriptions[$managerLang][0]->seo_keywords : '', ['class'=>'form-control']) !!}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label label-width">描述：</label>
                    <div class="col-sm-5">
                        {!! Form::textarea("description[{$managerLang}][seo_description]", isset($descriptions[$managerLang]) ? $descriptions[$managerLang][0]->seo_description : '', ['class'=>'form-control', 'rows'=>5]) !!}
                    </div>
                </div>
            </div>
        </div>
    </div>
     <div class="form-send-height">
     <div class="form-send-box">
         <div class="form-group">
             <label class="col-sm-3 control-label label-width"></label>
             <div class="col-sm-5">
               {!! Form::submit(inject('setting')->config('edit_auto_translate') == 1 ? '提交并翻译' : '提交', ['class'=>'btn btn-primary']) !!}
             </div>
         </div>
     </div>
 </div>  
{!! Form::close() !!}
@endsection

@section('foot')
<script src="{{ asset('data/assets/js/ueditor/ueditor.config.js') }}"></script>
<script src="{{ asset('data/assets/js/ueditor/ueditor.all.min.js') }}"></script>
<script src="{{ asset('data/assets/js/ueditor/addCustomizeButton.js') }}"></script>
<script type="text/javascript">
$(function(){
    UE.getEditor('editor-' + '{{ config('managerLang')  }}');
    var list = document.getElementById("picfram");
    new Sortable(list, {
        animation: 150,
    });
});
</script>
     <script>
         $(document).ready(function() {
             let parent_id = "{{ old('parent_id') }}"
             if (parent_id) {
                 $('.form-model').addClass('hidden')
                 $('.form-column').addClass('hidden')
                 if ($('.form-link').hasClass('hidden')) {
                     $('.form-link').removeClass('hidden')
                 }
                 $('#select-model').val('')
                 $('#select-column').val('')
             }

             $('#select-cate').change(function () {
                 let value = $(this).val()
                 if (value > 0) {
                     $('.form-model').addClass('hidden')
                     $('.form-column').addClass('hidden')
                     if ($('.form-link').hasClass('hidden')) {
                         $('.form-link').removeClass('hidden')
                     }
                     $('#select-model').val('')
                     $('#select-column').val('')
                 } else {
                     if ($('.form-model').hasClass('hidden')) {
                         $('.form-model').removeClass('hidden')
                     }
                 }
             })

             $('#select-model').change(function() {
                 let model = $(this).val()
                 let columns = $('#select-column')
                 if (model) {
                     $('.form-link').addClass('hidden')
                     $.ajax({
                         url: HOME_URL + '/admin/nav/get-column',
                         type: 'GET',
                         data: {content_model: model},
                         dataType: 'json',
                         success: function(data) {
                             columns.empty()
                             if (model !== 'page') {
                                 columns.append('<option value="">请选择</option>')
                             }
                             $.each(data.data, function(key, value) {
                                 columns.append('<option value="' + key + '">' + value + '</option>')
                             })
                         }
                     });
                     if ($('.form-column').hasClass('hidden')) {
                         $('.form-column').removeClass('hidden')
                     }
                 } else {
                     $('.form-column').addClass('hidden')
                     if ($('.form-link').hasClass('hidden')) {
                         $('.form-link').removeClass('hidden')
                     }
                     columns.empty()
                     columns.append('<option value="">请选择</option>')
                 }
             });
         });
     </script>
{{--媒体库 start--}}
@include('admin.common.media', ['type' => 'jpg,gif,png', 'multi' => true])
{{--媒体库 end--}}
@endsection