Files
orico-official-website-old/app/admin/view/webuploader/modal.html
2024-10-29 17:38:47 +08:00

201 lines
9.3 KiB
HTML
Executable File

<div id="filemanager" class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">文件管理器</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-5">
<a href="<?php echo $parent; ?>" data-toggle="tooltip" title="上一级" id="button-parent" class="btn btn-info"><i class="glyphicon glyphicon-level-up"></i></a>
<a href="<?php echo $refresh; ?>" data-toggle="tooltip" title="刷新" id="button-refresh" class="btn btn-info"><i class="glyphicon glyphicon-refresh"></i></a>
<a href="<?php echo $webuploader; ?>" data-toggle="tooltip" title="上传文件" id="button-webuploader" class="btn btn-info"><i class="glyphicon glyphicon-cloud-upload"></i></a>
<button type="button" data-toggle="tooltip" title="直接上传" id="button-upload" class="btn btn-primary"><i class="glyphicon glyphicon-upload"></i></button>
<button type="button" data-toggle="tooltip" title="新目录" id="button-folder" class="btn btn-info"><i class="glyphicon glyphicon-folder-close"></i></button>
<button type="button" data-toggle="tooltip" title="删除" id="button-delete" class="btn btn-danger"><i class="glyphicon glyphicon-trash"></i></button>
</div>
<div class="col-sm-7">
<div class="input-group">
<input type="text" name="search" value="<?php echo $filter_name; ?>" placeholder="检索中....." class="form-control">
<span class="input-group-btn">
<button type="button" data-toggle="tooltip" title="检索" id="button-search" class="btn btn-primary"><i class="glyphicon glyphicon-search"></i></button>
</span></div>
</div>
</div>
<hr />
<div class="row"><iframe id="uploadiframe" style="width:100%;min-height:200px;height:480px;" frameborder="0" src="<?php echo $uploadiframe; ?>"></iframe></div>
</div>
<div class="modal-footer"></div>
</div>
</div>
<script type="text/javascript">
$('#modal-image a.thumbnail').on('click', function(e) {
e.preventDefault();
var target = "<?php echo $target; ?>";
var thumb = "<?php echo $thumb; ?>";
var callback = "<?php echo $func;?>";
if (callback != "undefined") {
var fileurl_tmp = $(this).find('img').attr('src');
eval('window.parent.' + callback + '(fileurl_tmp,target,thumb);');
$('#modal-image').modal('hide');
return;
}
if (thumb) {
$('#' + thumb).find('img').attr('src', $(this).find('img').attr('src'));
}
if (target) {
$('#' + target).val($(this).parent().find('input').val());
}
$('#modal-image').modal('hide');
});
$('#modal-image a.directory').on('click', function(e) {
e.preventDefault();
$('#modal-image').load($(this).attr('href'));
});
$('#modal-image .pagination a').on('click', function(e) {
e.preventDefault();
$('#modal-image').load($(this).attr('href'));
});
$('#button-parent').on('click', function(e) {
e.preventDefault();
$('#modal-image').load($(this).attr('href'));
});
$('#button-refresh').on('click', function(e) {
e.preventDefault();
$('#modal-image').load($(this).attr('href'));
});
$('#button-webuploader').on('click', function(e) {
e.preventDefault();
$('#modal-image').load($(this).attr('href'));
});
$('#modal-image input[name=\'search\']').on('keydown', function(e) {
if (e.which == 13) {
$('#button-search').trigger('click');
}
});
$('#button-search').on('click', function(e) {
var url = '<?php echo url("/admin/webuploader/show",array_filter(["target"=>$target,"thumb"=>$thumb,"type"=>$type,"func"=>$func,"num"=>$num,"directory"=>$directory])); ?>';
var filter_name = $('#modal-image input[name=\'search\']').val();
if (filter_name) {
url += '&filter_name=' + encodeURIComponent(filter_name);
}
$('#modal-image').load(url);
});
</script>
<script type="text/javascript">
$('#button-upload').on('click', function(e) {
$('#form-upload').remove();
$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file[]" value="" multiple="multiple"/></form>');
$('#form-upload input[name=\'file[]\']').trigger('click');
if (typeof timer != 'undefined') {
clearInterval(timer);
}
timer = setInterval(function() {
if ($('#form-upload input[name=\'file[]\']').val() != '') {
clearInterval(timer);
$.ajax({
url: '<?php echo url("/admin/webuploader/upload",["directory"=>$directory,"type"=>$type]); ?>',
type: 'post',
dataType: 'json',
data: new FormData($('#form-upload')[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$('#button-upload i').replaceWith('<i class="glyphicon glyphicon-hourglass"></i>');
$('#button-upload').prop('disabled', true);
},
complete: function() {
$('#button-upload i').replaceWith('<i class="glyphicon glyphicon-upload"></i>');
$('#button-upload').prop('disabled', false);
},
success: function(json) {
if (json['error']) {
alert(json['error']);
}
if (json['success']) {
alert(json['success']);
$('#button-refresh').trigger('click');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
}, 500);
});
$('#button-folder').popover({
html: true,
placement: 'bottom',
trigger: 'click',
title: '文件夹名称',
content: function() {
var html = '<div class="input-group">';
html += ' <input type="text" name="folder" value="" placeholder="名称,仅支持数字字母下划线" class="form-control">';
html += ' <span class="input-group-btn"><button type="button" title="新目录" id="button-create" class="btn btn-primary"><i class="glyphicon glyphicon-plus-sign"></i></button></span>';
html += '</div>';
return html;
}
});
$('#button-folder').on('shown.bs.popover', function() {
$('#button-create').on('click', function() {
$.ajax({
url: '<?php echo url("/admin/webuploader/folder",["directory"=>$directory]); ?>',
type: 'post',
dataType: 'json',
data: 'folder=' + encodeURIComponent($('input[name=\'folder\']').val()),
beforeSend: function() {
$('#button-create').prop('disabled', true);
},
complete: function() {
$('#button-create').prop('disabled', false);
},
success: function(json) {
if (json['error']) {
alert(json['error']);
}
if (json['success']) {
alert(json['success']);
$('#button-refresh').trigger('click');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
});
$('#modal-image #button-delete').on('click', function(e) {
if (confirm('确定删除吗?')) {
$.ajax({
url: '<?php echo url("/admin/webuploader/delete",["directory"=>$directory]); ?>',
type: 'post',
dataType: 'json',
data: $('input[name^=\'path\']:checked'),
beforeSend: function() {
$('#button-delete').prop('disabled', true);
},
complete: function() {
$('#button-delete').prop('disabled', false);
},
success: function(json) {
if (json['error']) {
alert(json['error']);
}
if (json['success']) {
alert(json['success']);
$('#button-refresh').trigger('click');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
});
</script>