<?php $__env->startSection('css_page_level'); ?>
<link href="<?php echo e(asset('assets/global/plugins/jquery-file-upload/blueimp-gallery/blueimp-gallery.min.css')); ?>" rel="stylesheet"/>
<link href="<?php echo e(asset('assets/global/plugins/jquery-file-upload/css/jquery.fileupload.css')); ?>" rel="stylesheet"/>
<link href="<?php echo e(asset('assets/global/plugins/jquery-file-upload/css/jquery.fileupload-ui.css')); ?>" rel="stylesheet"/>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page-content-wrapper'); ?>
	<div class="page-content-wrapper" id="main">
		<div class="page-content">
			<!-- BEGIN PAGE HEADER-->
			<h3 class="page-title">
			<?php $setting = app('anlutro\LaravelSettings\Facade'); ?>
			<?php echo e($setting::get('system_name','全方位建築智慧化管理系統')); ?> <small><?php echo e($setting::get('company_name','新保科技')); ?></small>
			</h3>
			<div class="page-bar">
				<ul class="page-breadcrumb">
					<li>
						<i class="fa fa-home"></i>
						<a href="index.html"><?php echo app('translator')->get('messages.homepage'); ?></a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="#"><?php echo app('translator')->get('messages.community_manage'); ?></a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="#"><?php echo app('translator')->get('messages.add_doc'); ?></a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
					    <a href="#"><?php echo e($folders->name); ?></a>
					    <i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="#"><?php echo e($document->name); ?></a>
					</li>
				</ul>
				<div class="page-toolbar">

				</div>
			</div>
			<!-- END PAGE HEADER-->
			<!-- BEGIN PAGE CONTENT-->
			<div class="row">
				<div class="col-md-12">
					
				</div>
				<div class="col-md-12">
					<form id="fileupload" action="<?php echo e(action('Manage\Platform\DocumentController@storeFile')); ?>" method="POST" enctype="multipart/form-data">
						<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
						<div class="row fileupload-buttonbar">
							<div class="col-lg-7">
								<!-- The fileinput-button span is used to style the file input field as button -->
                                <span id="btn_add_movie" class="btn yellow">
                                    <i class="fa fa-plus"></i>
                                    <span>新增影音連結 </span>
                                </span>
								<span class="btn green fileinput-button">
								<i class="fa fa-plus"></i>
								<span>
								<?php echo app('translator')->get('messages.add_doc'); ?> </span>
								<input type="file" name="files[]" multiple="">
								</span>
								<button type="submit" class="btn blue start">
								<i class="fa fa-upload"></i>
								<span>
								<?php echo app('translator')->get('messages.start_upload'); ?> </span>
								</button>
								<button type="reset" class="btn warning cancel">
								<i class="fa fa-ban"></i>
								<span>
								<?php echo app('translator')->get('messages.cancel_upload'); ?> </span>
								</button>
								<button type="button" class="btn red delete">
								<i class="fa fa-trash"></i>
								<span>
								<?php echo app('translator')->get('messages.del'); ?> </span>
								</button>
								<a class="btn grey" onclick="window.history.go(-1); return false;">
									<?php echo app('translator')->get('messages.return_doc_folder'); ?>
								</a>

								&nbsp;&nbsp;<?php echo app('translator')->get('messages.select_all'); ?>&nbsp;<input type="checkbox" class="toggle">
								<!-- The global file processing state -->
								<span class="fileupload-process">
								</span>
							</div>
							<!-- The global progress information -->
							<div class="col-lg-5 fileupload-progress fade">
								<!-- The global progress bar -->
								<div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
									<div class="progress-bar progress-bar-success" style="width:0%;">
									</div>
								</div>
								<!-- The extended global progress information -->
								<div class="progress-extended">
									 &nbsp;
								</div>
							</div>
						</div>
						<!-- The table listing the files available for upload/download -->
						<table role="presentation" class="table table-striped clearfix">
						<tbody class="files">
						</tbody>
						</table>

					</form>
					<div class="panel panel-success">
						<div class="panel-heading">
							<h3 class="panel-title"><?php echo app('translator')->get('messages.remind_of_upload'); ?></h3>
						</div>
						<div class="panel-body">
							<ul>
								<li>
									 <?php echo app('translator')->get('messages.max_file_size'); ?><strong>35 MB</strong>，<?php echo app('translator')->get('messages.dont_upload_maxxx_file'); ?>
								</li>
								<li>
									 <?php echo app('translator')->get('messages.only_apply_type'); ?>(<strong>DOC, DOCX, PPT, PPTX, XLS, XLSX, TXT, JPG, PDF, MP4</strong>)。
								</li>
							</ul>
						</div>
					</div>
				</div>
			</div>
			<!-- END PAGE CONTENT-->
		</div>

    <div class="modal" id="modal_add_movie" role="dialog" aria-hidden="true">
        <div class="modal-dialog red">
            <form id="add_form" class="form-horizontal" method="POST" action="">
            <div class="modal-content">
                <div class="modal-header bg-red-sunglo">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title font-white">上傳影音連結</h4>
                </div>
                <div class="modal-body form">
                    <input type="hidden" id="_token" name="_token" value="<?php echo e(csrf_token()); ?>">
                    <input type="hidden" name="document_id" value="<?php echo e($id); ?>">
                    <div class="form-body">
                        <div class="form-group">
                            <label class="col-md-3 control-label">影音名稱</label>
                            <div class="col-md-8">
                                <input type="text" class="form-control" id="movie_name" name="name" placeholder="請輸入影音名稱">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label">影音連結</label>
                            <div class="col-md-8">
                                <input type="text" class="form-control" id="movie_file" name="file" placeholder="請貼上影音連結">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn default" data-dismiss="modal"><?php echo app('translator')->get('messages.close'); ?></button>
                    <button type="submit" class="btn blue" id="btn_form_add"><?php echo app('translator')->get('messages.upload'); ?></button>
                </div>
            </div>
            </form>
        </div>
    </div>

<!-- The blueimp Gallery widget -->
<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-filter=":even">
	<div class="slides">
	</div>
	<h3 class="title"></h3>
	<a class="prev">
	‹ </a>
	<a class="next">
	› </a>
	<a class="close white">
	</a>
	<a class="play-pause">
	</a>
	<ol class="indicator">
	</ol>
</div>
<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-upload fade">
        <td>
            <span class="preview"></span>
        </td>
        <td>
            <p class="name">{%=file.name%}</p>
            <strong class="error label label-danger"></strong>
        </td>
        <td>
        	<input name="name" type="text" class="form-control" placeholder="{%=file.name%}" value="{%=file.name%}">
        	<input type="hidden" id="_token" name="_token" value="<?php echo e(csrf_token()); ?>">
        	<input type="hidden" id="document_id" name="document_id" value="<?php echo e($id); ?>">
        </td>
        <td>
            <p class="size"><?php echo app('translator')->get('messages.sending'); ?>.........</p>
            <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
            <div class="progress-bar progress-bar-success" style="width:0%;"></div>
            </div>
        </td>
        <td>
            {% if (!i && !o.options.autoUpload) { %}
                <button class="btn blue start" disabled>
                    <i class="fa fa-upload"></i>
                    <span><?php echo app('translator')->get('messages.start'); ?></span>
                </button>
            {% } %}
            {% if (!i) { %}
                <button class="btn red cancel">
                    <i class="fa fa-ban"></i>
                    <span><?php echo app('translator')->get('messages.cancel'); ?></span>
                </button>
            {% } %}
        </td>
    </tr>
{% } %}
</script>
<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
        {% for (var i=0, file; file=o.files[i]; i++) { %}
            <tr class="template-download fade">
                <td>
                    <span class="preview">
                        {% if (file.thumbnailUrl) { %}
                            <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery><img src="{%=file.thumbnailUrl%}"></a>
                        {% } %}
                    </span>
                </td>
                <td>
                    <p class="name">
                        {% if (file.url) { %}
                            <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}}>{%=file.name%}</a>
                        {% } else { %}
                            <span>{%=file.name%}</span>
                        {% } %}
                    </p>
                    {% if (file.error) { %}
                        <div><span class="label label-danger"><?php echo app('translator')->get('messages.wrong_apply_type'); ?></span><?php echo app('translator')->get('messages.only_apply_type'); ?>(<strong>doc, docx, ppt, pptx, xls, xlsx, txt, jpg, pdf, mp4</strong>)。</div>
                    {% } %}
                </td>

                <td>
                    <span class="size">{%=o.formatFileSize(file.size)%}</span>
                </td>
                <td>
                    {% if (file.deleteUrl) { %}
                        <button class="btn red delete btn-sm" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
                            <i class="fa fa-trash-o"></i>
                            <span><?php echo app('translator')->get('messages.del'); ?></span>
                        </button>
                        <input type="checkbox" name="delete" value="<?php echo e($id); ?>" class="toggle">
                    {% } else { %}
                        <button class="btn yellow cancel btn-sm">
                            <i class="fa fa-ban"></i>
                            <span><?php echo app('translator')->get('messages.cancel_upload'); ?></span>
                        </button>
                    {% } %}
                </td>
            </tr>
        {% } %}
    </script>
	
<?php $__env->stopSection(); ?>

<?php $__env->startSection('plugins_page_level'); ?>
<script src="<?php echo e(asset('assets/global/plugins/fancybox/source/jquery.fancybox.pack.js')); ?>"></script>
<!-- BEGIN:File Upload Plugin JS files-->
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/vendor/jquery.ui.widget.js')); ?>"></script>
<!-- The Templates plugin is included to render the upload/download listings -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/vendor/tmpl.min.js')); ?>"></script>
<!-- The Load File plugin is included for the preview images and image resizing functionality -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/vendor/load-image.min.js')); ?>"></script>
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/vendor/canvas-to-blob.min.js')); ?>"></script>
<!-- blueimp Gallery script -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/blueimp-gallery/jquery.blueimp-gallery.min.js')); ?>"></script>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/jquery.iframe-transport.js')); ?>"></script>
<!-- The basic File Upload plugin -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/jquery.fileupload.js')); ?>"></script>
<!-- The File Upload processing plugin -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/jquery.fileupload-process.js')); ?>"></script>
<!-- The File Upload image preview & resize plugin -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/jquery.fileupload-image.js')); ?>"></script>
<!-- The File Upload audio preview plugin -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/jquery.fileupload-audio.js')); ?>"></script>
<!-- The File Upload video preview plugin -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/jquery.fileupload-video.js')); ?>"></script>
<!-- The File Upload validation plugin -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/jquery.fileupload-validate.js')); ?>"></script>
<!-- The File Upload user interface plugin -->
<script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/jquery.fileupload-ui.js')); ?>"></script>
<!-- The main application script -->
<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE 8 and IE 9 -->
<!--[if (gte IE 8)&(lt IE 10)]>
    <script src="<?php echo e(asset('assets/global/plugins/jquery-file-upload/js/cors/jquery.xdr-transport.js')); ?>"></script>
    <![endif]-->
<!-- END:File Upload Plugin JS files-->
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js_page_level'); ?>
<script>
$(document).ready(function(){
	$('#fileupload').fileupload({
        disableFileResize: false,
        autoUpload: false,
        disableFileResize: /Android(?!.*Chrome)|Opera/.test(window.navigator.userAgent),
        maxFileSize: 36700160,  //10 megabits = 10485760 bits
        acceptFileTypes: /(\.|\/)(doc|docx|ppt|pptx|xls|xlsx|txt|jpg|pdf|mp4)$/i,

        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},                
    });

    $('#fileupload').bind('fileuploadsubmit', function (e, data) {
	    var inputs = data.context.find(':input');
	    if (inputs.filter(function () {
	            return !this.value && $(this).prop('required');
	        }).first().focus().length) {
	        data.context.find('button').prop('disabled', false);
	        return false;
	    }
	    data.formData = inputs.serializeArray();
	});

    $(document).on('click','#btn_add_movie',function(){
        $('#modal_add_movie').modal('show');
    });

    $(document).on('click','#btn_form_add',function(e){
        if($('#movie_name').val() == ''){
            toastr['warning']('影音名稱請勿空白');
            e.preventDefault();
        }else if($('#movie_file').val() == ''){
            toastr['warning']('影音連結請勿空白');
            e.preventDefault();
        }else{
            var form = $('#add_form');
            form.attr("action", '<?php echo e(action('Manage\Platform\DocumentController@add_movie')); ?>');
            form.submit();
        }
    });
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layout.manage', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>