@extends('admin.master')

@section('top')
	<div class="top-breadcrumb">
        <h5>风格管理</h5>
    </div>
@endsection

@section('content')
@if(!empty($themes))
    <ul class="theme-list">
        @foreach ($themes as $value)
            <li>
                <div class="theme-list-img">
                    <img src="{{ url('themes/'.$value['dirname'].'/'.$value['preview']) }}">
                </div>
                <div class="theme-list-item">
                    <span>{{ $value['dirname'] }}</span>
                    <div class="theme-list-check">
                        启用该主题：
                        <i class="iconfont {{ $theme == $value['dirname'] ? 'icon-morendizhi' : 'icon-buxuanzhong' }}" data-dirname="{{ $value['dirname'] }}"></i>
                    </div>
                </div>
            </li>
        @endforeach
    </ul>
@else
    <div class="nodata-wrap">
        <div class="notice-null"><span class="inline-block">暂无数据</span></div>
    </div>
@endif

@endsection

@section('notice')

<!-- Modal -->
<div class="modal fade" id="dialog-tip" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="true"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">提示</h4>
        </div>
        <div class="modal-body clearfix">
			<div class='col-sm-1 text-center'><i class='glyphicon glyphicon-ok text-size-32 text-warning'></i></div>
			<div class='col-sm-11 breakall'><p class="delete-error">删除失败！</p></div>
		</div>	
        <div class="modal-footer">
			<button class="btn btn-primary btn-modal-close" data-dismiss="modal">确定</button>
        </div>
    </div>
  </div>
</div>
<!-- Modal End -->

<!-- Modal -->
<div class="modal fade" id="dialog-error" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="true"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">提示</h4>
        </div>
        <div class="modal-body clearfix">
			<div class='col-sm-1 text-center'><i class='fa fa-times-circle text-size-32 text-warning'></i></div>
			<div class='col-sm-11 breakall'><p class="delete-error">删除失败！</p></div>
		</div>	
        <div class="modal-footer">
			<button class="btn btn-primary btn-modal-close" data-dismiss="modal">确定</button>
        </div>
    </div>
  </div>
</div>
<!-- Modal End -->

@endsection

@section('foot')
<script src="{{ asset('data/assets/js/echarts.simple.min.js') }}"></script>
<script type="text/javascript">
    $('body').on('click', '.theme-list-item i', function() {
        var dirname = $(this).data('dirname');
        var url     = HOME_URL + '/admin/theme/change/' + dirname;
        var item    = $(this);
        $.get(url, function(data) {
            if (data.status == 'success') {
                $('.delete-error').html('更新成功！');
                $('#dialog-tip').modal('show');
                item.addClass('icon-morendizhi').removeClass('icon-buxuanzhong').parents('li').siblings().children('.theme-list-item').children('.theme-list-check').children('i').removeClass('icon-morendizhi').addClass('icon-buxuanzhong');
            } else {
                $('.delete-error').html('更新失败，请重新选择！');
                $('#dialog-error').modal('show');
            }
        });
    });
</script>
@endsection
