<?php

/**
 * iCMS - i Content Management System
 * Copyright (c) 2007-2017 iCMSdev.com. All rights reserved.
 *
 * @author icmsdev <master@icmsdev.com>
 * @site https://www.icmsdev.com
 * @licence https://www.icmsdev.com/LICENSE.html
 */
defined('iPHP') or exit('What are you doing?');
self::head();
?>
<script type="text/javascript">
    var settings = {
        pick: {
            id: '#filePicker',
            label: '点击选择图片'
        },
        fileVal: 'upfile',
        formData: {
            "udir": "<?php echo $_GET['dir']; ?>"
        },
        dnd: '#dndArea',
        paste: '#uploader',
        swf: './app/files/assets/webuploader/Uploader.swf',
        chunked: false,
        chunkSize: 512 * 1024,
        server: '<?php echo APP_URL; ?>&action=upload&CSRF_TOKEN=<?php echo Security::$CSRF_TOKEN; ?>',
        callback: {
            "uploadSuccess": function(a, b) {
                // console.log(b);
                if (b.state == 'SUCCESS') {
                    var state = window.parent.modal_<?php echo $this->callback; ?>(b,false);
                    if (state == 'off') {
                        window.parent.iCMS_MODAL.destroy();
                    }
                } else {
                    return iCMS.ui.alert(b.state);
                }

            },
            "startUpload": function(uploader) {
                var formData = uploader.option('formData');
                var checked = $("#noWatermark").prop("checked");
                if (!checked) formData['noWatermark'] = true;
                uploader.option('formData', formData);
                return false;
            }
        },
        // runtimeOrder: 'flash',

        // accept: {
        //     title: 'Images',
        //     extensions: 'gif,jpg,jpeg,bmp,png',
        //     mimeTypes: 'image/*'
        // },

        // 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候，把图片打开。
        disableGlobalDnd: true,
        fileNumLimit: 300,
        fileSizeLimit: 200 * 1024 * 1024, // 200 M
        fileSingleSizeLimit: 50 * 1024 * 1024 // 50 M
    }
</script>
<link rel="stylesheet" href="./app/files/assets/webuploader/webuploader.css" type="text/css" />
<link rel="stylesheet" href="./app/files/assets/webuploader/style.css" type="text/css" />
<script type="text/javascript" src="./app/files/assets/webuploader/webuploader.min.js"></script>
<script type="text/javascript" src="./app/files/assets/webuploader/upload.js"></script>

<div class="block">
    <div class="block-header block-header-default">
        <h3 class="block-title">文件列表</h3>
        <div class="block-options">
            <div class="block-options-item">
                <span class="badge badge-success" id="FilesUploaded" num="0" style="margin-top: 10px;">0个文件已上传</span>
            </div>
        </div>
    </div>
    <div class="block-content p-2">
        <div id="uploader">
            <div class="queueList">
                <div id="dndArea" class="placeholder">
                    <div id="filePicker"></div>
                    <p>或将照片拖到这里，单次最多可选300张</p>
                    <p>您可以尝试文件拖拽，使用QQ截屏工具，然后激活窗口后粘贴，或者点击添加图片按钮，来上传图片.</p>
                </div>
            </div>
            <div class="progress push" class="w-100" style="height: 10px;display:none;">
                <div class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
                    <span style="font-size: 12px;">0%</span>
                </div>
            </div>
            <div class="statusBar px-2" style="display:none;">
                <div class="row">
                    <div class="info col-sm-5"></div>
                    <div class="col-sm-7 text-center text-md-right">
                        <input type="checkbox" data-toggle="switch" data-label-text="水印" name="noWatermark" id="noWatermark" <?php echo Config::get('watermark.enable') ? 'checked' : ''; ?> />
                        <div id="filePicker2" class="btn btn-alt-primary"></div>
                        <div class="uploadBtn btn btn-success"><i class="fa fa-fw fa-upload"></i> 开始上传</div>
                    </div>
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>
</div>
</div>
<?php self::foot(); ?>