<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>可视化编辑</title>
  <meta name="csrf-token" content="{{ csrf_token() }}">
  <link rel="icon" href="{{ inject('setting')->config('brand_ico') }}" type="image/x-icon">
  <link rel="stylesheet" href="{{ config('system.icon_url') }}">
  <link rel="stylesheet" href="{{ asset('data/assets/css/app.css') }}">
  <link rel="stylesheet" href="{{ asset('data/assets/css/jquery.fancybox.min.css') }}">
  <style>
      html,body {
          height: 100% !important;
          overflow-y: hidden;
      }
  </style>
  <script>
      var HOME_URL  = '{{ url('/') }}';
      var url_upload = "{{ url('admin/upload') }}";
  </script>
  <script src="{{ asset('data/assets/js/ueditor/ueditor.config.js') }}"></script>
  <script src="{{ asset('data/assets/js/ueditor/ueditor.all.min.js') }}"></script>
</head>
<body>

@if($action == '')
<iframe id="visual-edit" style="overflow-x: auto; height: 100%;" name="visualEdit" width="100%" scrolling="yes" frameborder="0" marginwidth="0" marginheight="0" src="" data-newurl="{{ (isset($_COOKIE['visual_iframe_url']) && $_COOKIE['visual_iframe_url']) ? $_COOKIE['visual_iframe_url'] : url('?visualEdit=true') }}"></iframe>
@endif

@if($action == 'edit')
  <div style="padding: 30px;">
    {!! Form::model($config, ['route' => ['admin.visual.update'], 'method'=>'post', 'class'=>'form-horizontal']) !!}
  @if($type == 'img')
    <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="{{ $key }}">
          <div class="upload-wrap-btn {{ $config->get($key) ? 'display-none' : ''}}">
            <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($config->get($key))
              <li class="thumbnail" data-img="{{ $config[$key] }}">
                <input name="{{ $key }}" value="{{ $config[$key] }}" type="hidden">
                <a class="thumbnail-img"><img src="{{ url($config[$key]) }}"></a>
                <a class="thumbnail-remove" data-id='fileupload' href="javascript:;">删除</a>
              </li>
            @endif
          </ul>
        </div>
      </div>
    </div>
  @endif

    @if($type == 'text')
      <div class="form-group">
        <label class="col-sm-2 control-label label-width">文字：</label>
        <div class="col-sm-5">
          @if(in_array($key, ['site_title', 'meta_keywords', 'meta_description', 'tag_description', 'title', 'address', 'contact']))
            {!! Form::textarea("description[en][$key]", isset($descriptions['en']) ? $descriptions['en']->pluck('value', 'name')->get($key) : '', ['class'=>'form-control', 'rows'=>5]) !!}
          @else
            {!! Form::textarea($key, "{{ $config[$key] }}", ['class'=>'form-control', 'rows'=>5]) !!}
          @endif
        </div>
      </div>
    @endif

    @if($type == 'editor')
      <div class="form-group">
        <label class="col-sm-2 control-label label-width">内容：</label>
        <div class="col-sm-10">
          {!! Form::textarea("description[en][$key]", isset($descriptions['en']) ? $descriptions['en']->pluck('value', 'name')->get($key) : '', ['id'=>"editor-en", 'class'=>'len-full']) !!}
        </div>
      </div>
      <script>
          UE.getEditor('editor-en');
      </script>
    @endif

    <div class="form-group">
      <label class="col-sm-3 control-label label-width"></label>
      <div class="col-sm-5">
        {!! Form::submit('提交', ['class'=>'btn btn-primary']) !!}
      </div>
    </div>
    {!! Form::close() !!}
  </div>
@endif

<script src="{{ asset('data/assets/js/app.js') }}"></script>
<script src="{{ asset('data/assets/js/jquery.fancybox.min.js') }}"></script>
<script src="{{ asset('data/assets/js/visual.js') }}"></script>
<script src="{{ asset('data/assets/js/upload/plupload.full.min.js') }}"></script>
<script src="{{ asset('data/assets/js/fileupload.js') }}"></script>
{{--媒体库 start--}}
@include('admin.common.media', ['type' => 'jpg,gif,png'])
{{--媒体库 end--}}
</body>
</html>